This is because you havenβt done anything yet, when you do git checkout -b test , git changes the contents of the .git/HEAD file from ref: refs/heads/master to ref: refs/heads/test , which actually does not indicate anything . Only after you commit, git create test refs for you, and you find the .git/refs/heads/test file containing the hash of the commit just made.
source share