突然无法创建本地/远程git分支

时间:2011-02-18 04:32:19

标签: git shell unix

不知道我是如何管理这个的,但我不能再创建本地和远程分支了。

~/myapp(master) > git checkout -b new_feature origin/new_feature
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/new_feature' which can not be resolved as commit?

我已尝试重新克隆我的应用,以防.git目录已损坏,但没有运气。有什么建议吗?

2 个答案:

答案 0 :(得分:3)

您不能以这种方式创建远程分支,您需要先git checkout -b new_feature创建新的本地分支,然后git push origin new_feature将分支推送到远程。

答案 1 :(得分:2)

尝试以下方法之一:

  • 创建本地分支:git branch some_branch

  • 使用(结帐)该分支(这不是自动的):git checkout some_branch

  • 创建远程分支:git push origin origin:refs/heads/some_branch

  • 结帐(和跟踪)远程分支(如果尚不存在,则创建local_branch):git branch --track local_branch origin/remote_branch

相关问题