簡體   English   中英

如何從遠程標簽執行“git checkout -b <branchname>”

[英]How to do a “git checkout -b <branchname>” from a remote tag

我正在嘗試從遠程標簽創建一個分支,但似乎沒有辦法做到這一點。 當我嘗試

git checkout -b test origin/deploy

原點是遠程的,部署是我要檢查的標簽,但我明白了

fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/deploy' which can not be resolved as commit?

更新:我剛剛發現了

git fetch --all -t

我的工作不正常。 當它下載所有分支時,它不會下載所有標簽,因此當我簽出部署時它是舊標簽。 現在我執行

git fetch --all && git fetch -t

這樣,當我基於標簽創建新分支時

git checkout -b test deploy

新分支是最新部署的最新版本。

我不確定你能直接做到這一點。 你可能會堅持做一個獲取然后結賬:

git fetch origin
git checkout -b test tag-name

順便說一句,我不建議使用像“部署”這樣的標簽名稱。

我不是一個git guru,但我之前使用過這樣的東西,它似乎運行良好:

git pull (or fetch, just need to make sure you are updated)
git checkout -b test remotes/origin/deploy

你需要跑

git pull
git checkout -b <new-branch-name> remotes/origin/<source-branch-name>

列出所有標簽

git fetch
git tags -l 

創建指向標記的本地分支

git checkout tags/<tag_name> -b <branch_name>
git checkout -b <branch_name> tags/<tag_name>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM