From 8f0df347d815fe02e040a439bef62f8a706033ad Mon Sep 17 00:00:00 2001 From: Siarhei Bobryk Date: Sat, 1 Jun 2019 17:52:33 +0300 Subject: [PATCH] Note about SHA-1 values in the HEAD file I'd like to add some notes about the HEAD file content which I think should be in this book section. Unfortunately I'm not English native speaker so please correct me if I did grammar or other mistakes. --- book/10-git-internals/sections/refs.asc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/book/10-git-internals/sections/refs.asc b/book/10-git-internals/sections/refs.asc index 0f7b84bd9..b680def3e 100644 --- a/book/10-git-internals/sections/refs.asc +++ b/book/10-git-internals/sections/refs.asc @@ -70,8 +70,12 @@ When you run commands like `git branch `, Git basically runs that `updat The question now is, when you run `git 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]