$ ./guess_the_languageGit
Git · medium · #37

What does .git/HEAD contain now?

$ git checkout 3f9c2a1
You are in 'detached HEAD' state.
$ cat .git/HEAD
  1. ref: refs/heads/main
  2. A raw 40-character commit hash
  3. An empty file until you commit
  4. ref: refs/heads/3f9c2a1
Normally HEAD is a symbolic ref like ref: refs/heads/main. When detached it holds the commit ID directly.
Play Git ▸