无法设置跟踪信息; 起点'origin/master'不是分支

use*_*301 12 git

有人可以解释为什么这不起作用?

?  workspace git:(REL-BRANCH-1.0.1d) ? git branch -a
  REL-BRANCH-1.0.1c
* REL-BRANCH-1.0.1d
  remotes/origin/REL-BRANCH-1.0.1c
  remotes/origin/master
?  workspace git:(REL-BRANCH-1.0.1d) ? git checkout -t origin/master 
fatal: Cannot setup tracking information; starting point 'origin/master' is not a branch.
?  workspace git:(REL-BRANCH-1.0.1d) ? git checkout -t remotes/origin/master
fatal: Cannot setup tracking information; starting point 'remotes/origin/master' is not a branch.
Run Code Online (Sandbox Code Playgroud)

ans*_*wen 20

可能您的原始远程设置为仅提取某些分支.一个简单的

git remote set-branches --add origin master
Run Code Online (Sandbox Code Playgroud)

会解决它.


tom*_*row 7

对于通过谷歌到达这里的任何人来说,如果遇到同样的问题(“相同”,我的意思是相同的错误消息,而不是相同的原因),使用“git svn”而不仅仅是“git”:

删除 -t 选项可能会有所帮助,如下所述:git-svn:无法设置跟踪信息;起点不是分支


Vic*_*ema 5

您的 repo 可能包含要求 fetch 命令仅检索某些特定分支而不是全部分支的配置。您可以检查您使用的配置

git config --local --get-all remote.origin.fetch
Run Code Online (Sandbox Code Playgroud)

它可以返回诸如+refs/heads/*:refs/remotes/origin/*,+refs/heads/master:refs/remotes/origin/master或 之类的行+refs/heads/AnyOtherBranch:refs/remotes/origin/AnyOtherBranch。第一个配置字符串意味着它获取所有分支。第二个和第三个是仅针对特定分支的 fetch 配置示例。如果你没有带星号的配置行,那么你可以使用

# Reset "remote.origin.fetch" to deal with all branches
git remote set-branches origin '*'
Run Code Online (Sandbox Code Playgroud)

或者

# Append new config line for specific branch
git remote set-branches --add origin AnyOtherBranch
Run Code Online (Sandbox Code Playgroud)

  • `git Remote set-branches origin '*'` 解决了我的问题。谢谢! (4认同)