I ended up with a detached head today, the same problem as described in: git push says everything up-to-date even though I have local changes
As far as I know I didn
I reproduced this just now by accident:
lists the remote branches
git branch -r
origin/Feature/f1234
origin/master
I want to checkout one locally, so I cut paste:
git checkout origin/Feature/f1234
Presto! Detached HEAD state
You are in 'detached HEAD' state. [...])
Solution #1:
Do not include origin/
at the front of my branch spec when checking it out:
git checkout Feature/f1234
Solution #2:
Add -b
parameter which creates a local branch from the remote
git checkout -b origin/Feature/f1234
or
git checkout -b Feature/f1234
it will fall back to origin automatically