Interview Prep/Git & GitHub/Git internals: objects, refs and the index

What is HEAD?

BeginnerConceptGit internals: objects, refs and the index
Answer

HEAD is a reference to your current position, normally a symbolic ref pointing at a branch such as ref: refs/heads/main. When you commit, Git creates the commit and advances the branch HEAD points to. git switch rewrites HEAD to point at another branch.

cat .git/HEAD
git symbolic-ref HEAD
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index