網站首頁 編程語言 正文
拉取項目
執行命令git clone:
git clone git@github.com:secbr/nacos.git
查看遠程tag
執行命令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
執行命令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處于游離狀態,我們可以很方便地在歷史版本之間互相切換,比如需要回到某次提交,直接checkout對應的 commit id或者tag名即可。
但在這個基礎上的提交會新開一個匿名分支!也就是說我們的提交是無法可見保存的,一旦切到別的分支,游離狀態以后的提交就不可追溯了。
解決辦法就是新建一個分支保存游離狀態后的提交。
checkout作為一個分支
執行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
在游離狀態下的tag中執行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'.
原文鏈接:https://blog.csdn.net/wo541075754/article/details/118759685
相關推薦
- 2022-04-11 獲取base64編碼格式的圖片大小
- 2023-07-02 Linux系統下如何實現修改主機名_Linux
- 2022-02-18 Zabbix Database error
- 2022-05-21 Unity為軟件添加使用有效期的具體步驟_C#教程
- 2022-06-08 淺談C#多線程下的調優_C#教程
- 2022-12-11 Golang?內存模型The?Go?Memory?Model_Golang
- 2022-02-24 Oracle中decode函數用法_oracle
- 2022-06-10 Linux環境下部署Consul集群_Linux
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支