Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding detached HEAD in git [duplicate]

Tags:

git

If you are working in your repo and do git checkout <SHA> you will be in a "detached HEAD". You are not on a branch (the commit is likely to be on multiple branches). You are checked out to a specific instance in the history.

A detached head can also occur when you are rebasing. You are checked out to a specific commit.

You would need to create a branch in order to commit/push changes because you would be creating commits that would be "in limbo" with no way to identify them other than the SHA. Git will remove the commit during its garbage collection because of it not being on a branch.

Checkout the "Detached Head" Section on this page for more in depth information: http://git-scm.com/docs/git-checkout