Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions book/10-git-internals/sections/refs.asc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ When you run commands like `git branch <branch>`, Git basically runs that `updat
The question now is, when you run `git branch <branch>`, how does Git know the SHA-1 of the last commit?
The answer is the HEAD file.

The HEAD file is a symbolic reference to the branch you're currently on.
By symbolic reference, we mean that unlike a normal reference, it doesn't generally contain a SHA-1 value but rather a pointer to another reference.
Usually the HEAD file is a symbolic reference to the branch you're currently on.
By symbolic reference, we mean that unlike a normal reference, it contains a pointer to another reference.

However in some rare cases the HEAD file may contain the SHA-1 value of a git object.
This happens when you checkout a tag, commit, or remote branch, which puts your repository in https://git-scm.com/docs/git-checkout#_detached_head["detached HEAD"] state.

If you look at the file, you'll normally see something like this:

[source,console]
Expand Down