Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot update paths and switch to branch at the same time"

I sometimes use the checkout -b option to create a new branch, check it out at the same time and set up tracking in one command.

In a new environment, I get this error:

$ git checkout -b test --track origin/master fatal: Cannot update paths and switch to branch 'test' at the same time. Did you intend to checkout 'origin/master' which can not be resolved as commit? 

Why does Git not like it? This used to work with the same repo.

like image 374
marekful Avatar asked Apr 10 '14 09:04

marekful


1 Answers

'origin/master' which can not be resolved as commit

Strange: you need to check your remotes:

git remote -v 

And make sure origin is fetched:

git fetch origin 

Then:

git branch -avv 

(to see if you do have fetched an origin/master branch)

Finally, use git switch instead of the confusing git checkout, with Git 2.23+ (August 2019).

git switch -c test --track origin/master 
like image 74
VonC Avatar answered Sep 17 '22 23:09

VonC