git切换远程分支报错: Cannot update paths and switch to branch at the same time

执行切换远程分支:

git checkout -b fork-1.1.1 origin/fork-1.1.1

报错:

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

这是因为本地没有fetch远程origin的信息,所以先要执行

git remote -v
git fetch origin

确定origin is fetched, 然后执行

git checkout -b fork-1.1.1 origin/fork-1.1.1

Branch fork-1.1.1 set up to track remote branch fork-1.1.1 from origin.
Switched to a new branch 'fork-1.1.1'

这里就能成功,切换回master命令

git checkout master

你可能感兴趣的:(git)