簡體   English   中英

如何獲得遠程分支並使用git和vsts切換到它?

[英]How to get remote branch and switch to it with git and vsts?

我有一個本地存儲庫,該本地存儲庫在Visual Studio Team Services(VSTS)中跟蹤遠程存儲庫,當前位於分支主服務器中。 一位同事已將新功能分支推送到遙控器。 我想拉那個遙控器並切換到它。 我嘗試了以下方法:

git pull
git pull --all
git branch

在本地不顯示新的遠程分支。 我也試過

git checkout -b FeatureBranch origin/FeatureBranch

但是我得到這個錯誤:

fatal: Cannot update paths and switch to branch 'FeatureBranch' at the same time.
Did you intend to checkout 'origin/FeatureBranch' which can not be resolved as commit?

也嘗試過

git checkout --track origin/FeatureBranch

我認為與先前的命令相同,並得到相同的錯誤。 有什么想法我做錯了嗎?

git status

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

pull僅獲取要集成的遠程分支。 您應該改用fetch來用遠程分支來更新本地存儲庫中的所有遠程跟蹤分支。 之后,您的命令應該可以運行,並且git branch -agit branch -r將顯示該分支。 同樣,在獲取它之后,如果它不在多個遠程服務器中,您甚至可以簡單地執行git checkout FeatureBranch ,它隱式地與git checkout -b FeatureBranch origin/FeatureBranch ,除非您使用的是古老的Git版本。

暫無
暫無

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

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