Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is HEAD in Git?

SHORT ANSWER

HEAD is a pointer to the commit you currently have checked out. Normally it points to a branch name, which points to that branch's latest commit, so HEAD marks where your next commit will be added.

Explain it simply

HEAD is the 'You are here' arrow on a railway map. The branches are named stations, and HEAD says which station you are standing at right now.

Usually HEAD does not point at a commit directly. It points at a branch such as main, and the branch points at its latest commit. When you commit, the branch moves forward and HEAD moves with it. Shortcuts such as HEAD~1 mean the parent of the current commit, and HEAD~3 means three commits back. The value is stored in the file .git/HEAD.

Example

bash
cat .git/HEAD          # ref: refs/heads/main
git log -1 HEAD        # the commit you are on
git show HEAD~1        # the commit before it
git diff HEAD          # working tree versus the last commit

What to say in the interview

"HEAD is a reference to the currently checked-out commit, usually through a branch. When I commit, the branch advances and HEAD follows. I use HEAD~1 or HEAD~2 to refer to earlier commits, for example in git reset HEAD~1 or git diff HEAD."

Common mistakes

  • Thinking HEAD is the same thing as the branch; it points to the branch, or directly to a commit when detached.

#git#head#basics

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.