当我使用以下命令(两个分支均已存在)切换到branch2
时,我正在branch1
上:
git checkout origin/branch2
然后我遇到了一个分离头错误:
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 performing another checkout.
然后我只是检出 branch2
(不带 origin
),然后它就可以正常工作:
git checkout branch2
那么使用 git checkout
时带上和不带上 origin/
的区别是什么?为什么在使用 origin/
时会出现 detached HEAD
错误?