Git问题:Cannot update paths and switch to branch 'dev' at the same time.

在创建远程分支时,发生了下面的错误:

$ git checkout -b dev origin/dev

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

上网搜了好多资料都没能解决,最后到了StackOverflow上查到了答案:链接
Git问题:Cannot update paths and switch to branch 'dev' at the same time._第1张图片

翻译:(勿喷)

正如我在“Get new upstream branch with git”中提到的那样,你可以尝试一下下面的命令:

# let's create a new local branch first
#我们来创建一个新的本地分支
git checkout -b iss53
# then reset its starting point
#然后重置它的起始点
git reset --hard origin/iss53

确保运行git fetch origin命令后原创跟踪的分支origin/iss53要存在。

origin/iss53意味着origin索引的远程仓库有iss53分支。

如果原创仓库中没有origin/iss53这个分支的话,你只需创建一个本地分支iss53,然后将它推送到远程仓库即可:

git push -u origin iss53 

这样的话就会在本地的分支iss53和原创跟踪的分支origin/iss53之间建立一个联系。

你可能感兴趣的:(Git)