Git HEAD: The Current Branch and Symbolic References
Understand HEAD as the per-worktree symbolic reference to the current branch, distinguish it from a branch tip, observe attached HEAD, and recognize the unborn-branch boundary before detached HEAD.
Intermediate
HEAD names the current branch
V431 established that local branches are refs under refs/heads/, and V433 established that switching changes which named branch is current. This lesson owns the missing link: in the normal attached state, HEAD is a symbolic reference to the current branch. If HEAD points to refs/heads/main, HEAD does not contain the commit ID of main; it names the branch, and that branch ref resolves to the commit.
git symbolic-ref HEAD
git symbolic-ref --short HEAD
git rev-parse --symbolic-full-name HEAD
git rev-parse HEADQuick check
In the normal attached state, what does HEAD identify first?
main is current and attached.refs/heads/main is the symbolic target; HEAD resolves onward to main’s commit.
A symbolic reference is not the same thing as a branch tip
A branch name such as refs/heads/main directly identifies a branch tip commit. HEAD is different: it is a symbolic reference whose target is the branch name. This extra level is why moving main changes the commit reached through HEAD while the HEAD relationship itself remains attached to main.
git symbolic-ref HEAD refs/heads/main
git rev-parse --verify refs/heads/main^{commit}
git rev-parse --verify HEAD^{commit}Quick check
Which statement best distinguishes HEAD from refs/heads/main?
HEAD targets refs/heads/main.Both resolve to the same commit, but through different reference roles.
Moving the branch moves what HEAD resolves to
When the current branch advances by a commit, the branch ref moves. HEAD remains attached to that branch. Therefore HEAD^{commit} changes because the branch tip changed; HEAD itself does not need to be rewritten to a different branch name.
git branch --show-current
git rev-parse --symbolic-full-name HEAD
git rev-parse HEAD^{commit}
git commit -m "advance current branch"
git rev-parse --symbolic-full-name HEAD
git rev-parse HEAD^{commit}Quick check
After a normal commit on main, what changes in the attached HEAD model?
HEAD targets refs/heads/main before the commit.HEAD still targets refs/heads/main; that ref now resolves to the new commit.
HEAD and branch names can be inspected without reading implementation files
Use Git’s reference-aware commands to observe the model. `git symbolic-ref HEAD` answers which branch HEAD names. `git rev-parse --symbolic-full-name HEAD` exposes the fully qualified symbolic name. `git rev-parse HEAD` resolves HEAD to the current commit object ID. These observations are stronger than inferring state from the displayed prompt or from a directory listing.
git symbolic-ref HEAD
git rev-parse --symbolic-full-name HEAD
git rev-parse --verify HEAD^{commit}
git branch --show-currentQuick check
Why is `git symbolic-ref HEAD` useful in this lesson?
HEAD is attached to a named branch.The command reports that branch’s fully qualified ref path.
The unborn branch is still an attached HEAD state
A newly initialized repository can have an unborn branch: HEAD points symbolically at a branch name that does not yet exist as a commit-bearing ref. This is not detached HEAD. HEAD still names the intended current branch; that branch simply has no commit yet.
git init -b main repo
cd repo
git symbolic-ref HEAD
git rev-parse --verify HEAD^{commit}Quick check
What is true of HEAD in a newly initialized unborn main branch?
The repository has no commits yet.HEAD names the intended branch, but resolving it to a commit fails because the branch is unborn.
HEAD is per-worktree state
Git’s official glossary identifies HEAD as a per-worktree ref. This matters because a repository can have multiple worktrees: each worktree can have its own current HEAD while sharing repository objects and ordinary refs. The multi-worktree architecture is a later topic; here the important fact is that HEAD describes the current state of this worktree, not a universal repository-wide branch selector.
Quick check
Which statement is precise about HEAD in Git’s worktree model?
One repository may have multiple attached worktrees.Each worktree can maintain its own HEAD.
Detached HEAD is a different representation
This lesson deliberately stops before detached HEAD. In the normal state, HEAD symbolically names a branch. In detached HEAD, HEAD directly references a commit instead. That changes the relationship between HEAD and branch refs and deserves its own laboratory in the next lesson. Do not describe detached HEAD as “HEAD pointing to a branch with no name”; it is a different reference form.
Quick check
What conceptual change is reserved for the detached-HEAD lesson?
The repository is in the normal attached state.The next lesson will demonstrate the alternate HEAD representation.
Practice what you learned
Use the dedicated Git code-completion exercise for this lesson.
Official-source boundary
This lesson uses only official Git documentation: git-symbolic-ref, git-rev-parse, the Git glossary, and the official branch/switch documentation. The local verifier is Git 2.47.3. Version-sensitive behavior is reported from execution rather than assumed from documentation alone.
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.