In normal states, it’s actually a symbolic ref to the branch you have checked out (i.e “ref: refs/heads/master”). Therefore, in the normal state, HEAD effectively refers to the commit at the tip of the current branch.

It’s also possible to have a “detached HEAD”. This happens when you check out something besides a (local) branch, like a remote branch, a specific commit, or a tag. The most common place to see this is during an interactive rebase, when you choose to edit a commit. In detached HEAD state, your HEAD is a direct reference to a commit.

Generally speaking, HEAD is just a convenient name to mean “what you have checked out” and you don’t really have to worry much about it. Just be aware of what you have checked out, and remember that you probably don’t want to commit if you’re not on a branch (detached HEAD state) unless you know what you’re doing (e.g. are in an interactive rebase).

Git HEAD is important because it makes us be aware of what we have checked out and to know when to commit.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.