我的问题与 Fatal Git error when switching branch 有关.
我尝试使用命令获取远程分支
git checkout -b local-name origin/remote-name
但我收到此错误消息:
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/remote-name' which can not be resolved as commit?
如果我手动创建一个分支然后 pull 远程分支,它就可以工作,就像创建一个新的克隆并 check out 分支一样。
为什么它在我使用的存储库上不起作用?
最佳答案
我相信当您尝试 checkout 您的本地 git 存储库还不知道的远程分支时会发生这种情况。尝试:
git remote show origin
如果您要 check out 的远程分支在“新远程分支”下而不是“跟踪远程分支”下,那么您需要先获取它们:
git remote update
git fetch
现在它应该可以工作了:
git checkout -b local-name origin/remote-name
关于Git checkout : updating paths is incompatible with switching branches,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/945654/