“You are in ‘detached HEAD’ state” is not an error message and is nothing to be worried about.
This state means you are no longer on a branch, and it happens when an arbitrary commit is checked out instead of a branch.
If this state was unintentional and you want to “fix” the ‘detached HEAD’, you can go back to the branch you are expected to be on by runing the
git checkout command.
Fix Git ‘detached HEAD’
Note: Any commits you make in ‘detached HEAD’ mode will get lost once you switch to the previous branch.
Return back to the previous branch from the ‘detached HEAD’ state:
$ git checkout -
If you have already committed some changes in the ‘detached HEAD’ and don’t want to loose them, you can save these changes in a temporary branch:
$ git checkout -b <temporary-branch-name>
Later that temporary branch can be integrated into some other branch, e.g.
$ git checkout master $ git merge <temporary-branch-name>
Cool Tip: Move back and forth between two branches in Git! Read more →