What is "HEAD" in Git?
When working with Git, only one branch can be checked out at a time - and this is what's called the "HEAD" branch. Often, this is also referred to as the "active" or "current" branch.
Git makes note of this current branch in a file located inside the Git repository, in .git/HEAD
. (This is an internal file, so it should not be manually manipulated!)
If you wonder what exactly this file contains, you can simply have its contents printed on the command line:
$ cat .git/HEAD
ref: refs/heads/master
In this example case, a local branch named "master" is the current HEAD.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Detached HEAD
In rare cases, the HEAD file does NOT contain a branch reference, but a SHA-1 value of a specific revision. This happens when you checkout a specific commit, tag, or remote branch. Your repository is then in a state called Detached HEAD.
Tip
The HEAD in Tower
In case you are using the Tower Git client, changing the HEAD branch is easy as pie. Simply double-click a branch in the sidebar to make it the new HEAD branch - or choose a branch from a list.
Learn More
- Check out the overview for git checkout in our command reference
- More frequently asked questions about Git & version control