最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Git如何實現(xiàn)checkout遠程tag

 更新時間:2022年09月22日 15:49:39   作者:程序新視界  
這篇文章主要介紹了Git如何實現(xiàn)checkout遠程tag,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

拉取項目

執(zhí)行命令git clone:

git clone git@github.com:secbr/nacos.git

查看遠程tag

執(zhí)行命令git tag:

appledeMacBook-Pro-2:nacos apple$ git tag
0.2.1
0.2.1-RC1
0.3.0
0.3.0-RC1
0.4.0
...

此時可找到需要拉取的tag名稱。

checkout需要的tag

執(zhí)行命令git checkout:

(base) appledeMacBook-Pro-2:nacos apple$ git checkout 2.0.2
Note: switching to '2.0.2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

? git switch -c <new-branch-name>

Or undo this operation with:

? git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 1fac5c833 Merge pull request #6052 from alibaba/develop

其中2.0.2為tag(分支)名稱。

通過git branch命令可以查看當前的分支情況:

(base) appledeMacBook-Pro-2:nacos apple$ git branch
* (HEAD detached at 2.0.2)
? develop

通過此種方式,獲得的分支Head處于游離狀態(tài),我們可以很方便地在歷史版本之間互相切換,比如需要回到某次提交,直接checkout對應的 commit id或者tag名即可。

但在這個基礎上的提交會新開一個匿名分支!也就是說我們的提交是無法可見保存的,一旦切到別的分支,游離狀態(tài)以后的提交就不可追溯了。

解決辦法就是新建一個分支保存游離狀態(tài)后的提交。

checkout作為一個分支

執(zhí)行git checkout -b tagName (將tag checkout出去作為一個branch):

(base) appledeMacBook-Pro-2:nacos apple$ git checkout -b tag-2.0.2
Switched to a new branch 'tag-2.0.2'
(base) appledeMacBook-Pro-2:nacos apple$ git branch
? develop
* tag-2.0.2
(base) appledeMacBook-Pro-2:nacos apple$ git checkout -b tag-2.0.2
Switched to a new branch 'tag-2.0.2'
(base) appledeMacBook-Pro-2:nacos apple$ git branch
? develop
* tag-2.0.2

在游離狀態(tài)下的tag中執(zhí)行git checkout -b tag-2.0.2來新建一個分支。

當然上述checkout tag和checkout tag作為一個分支,可以合并成一個命令:

(base) appledeMacBook-Pro-2:nacos apple$ git checkout -b tag-1.4.2 1.4.2
Switched to a new branch 'tag-1.4.2'

上述命令,將遠程版本為1.4.2的tag,新建一個本地分支,名稱為tag-1.4.2。

添加遠程倉庫

(base) appledeMacBook-Pro-2:nacos apple$ git remote add tag-2.0.2 git@github.com:secbr/nacos.git

push并設置upstream

(base) appledeMacBook-Pro-2:nacos apple$ git push
fatal: The current branch tag-2.0.2 has no upstream branch.
To push the current branch and set the remote as upstream, use

? ? git push --set-upstream origin tag-2.0.2

(base) appledeMacBook-Pro-2:nacos apple$ git push --set-upstream origin tag-2.0.2
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'tag-2.0.2' on GitHub by visiting:
remote: ? ? ?https://github.com/secbr/nacos/pull/new/tag-2.0.2
remote:
To github.com:secbr/nacos.git
?* [new branch] ? ? ? ? ?tag-2.0.2 -> tag-2.0.2
Branch 'tag-2.0.2' set up to track remote branch 'tag-2.0.2' from 'origin'.

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。 

相關文章

最新評論

政和县| 泗阳县| 玉门市| 常山县| 平潭县| 岳普湖县| 通渭县| 西乌| 通州市| 革吉县| 新河县| 莱西市| 渑池县| 贺兰县| 蒙阴县| 稻城县| 宝丰县| 大埔县| 东辽县| 英山县| 崇明县| 青海省| 仁怀市| 平安县| 中西区| 交口县| 亚东县| 巴南区| 江津市| 方山县| 大竹县| 正蓝旗| 雷州市| 景谷| 高尔夫| 日喀则市| 南雄市| 永登县| 桃园市| 环江| 封开县|