Fix a detached head on Git


Open a terminal and, under your git directory, create a new temporary branch (e.g. temp):

git branch temp

Switch on the new branch typing:

git checkout temp

Point the master to the new branch (force it with option -f):

git branch -f master temp

Switch back on the master and delete the temporary branch:

git checkout master

git branch -d temp

That’s it. Everything should be went back to normal.

Leave a comment

Your email address will not be published. Required fields are marked *