HEAD

HEAD is a pointer to the commit you are currently working on — usually the latest commit of your current branch. It tells Git where you are in the project's history.

Git & DevOps

Most of the time HEAD points at a branch, which in turn points at its newest commit. When you switch branches, HEAD moves with you.

If you check out a specific commit directly instead of a branch, you enter a 'detached HEAD' state, where new commits aren't attached to any branch.

Examples

Bash

git log --oneline -1 HEAD

Output:

4b8c7d2 (HEAD -> main) Add homepage heading

Learn it in a lesson

See also

Back to the Dictionary