Here is a list of all my branches:
$ git branch -a
* temp
remotes/heroku/master
remotes/origin/dev
remotes/origin/master
When I type git checkout remotes/origin/master
to switch to my origin master
branch, Git switches to a detached HEAD state. Why?
This is the right behavior since you have checked out the remote branch.
If you wish to check out master and work on it you should do this now:
# checkout remote branch as local branch
# this will look up the branch name locally and if it does not find it it
#will checkout your remote branch with this name.
git checkout master
When you checkout remote branch you are simply pointing your HEAD to the latest commit from this branch. If you wish to work on it you have to check it out as local branch without the remote/<branch>
. This will automatically checkout and create local branch with the given name.
If you wish to learn more about the HEAD read all about it here.
A detached HEAD mean that your HEAD point to a commit which is not the lates in the commit chain.
In this sample commit #4 is the latest while the HEAD is pointing to commit #2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With