I know that, in Git parlance, \"detached HEAD\" corresponds to a state in which the symbolic reference HEAD
is not pointing to any branch. I also know that
With Git 2.4+ (Q2 2015), git log --decorate
will shows the exact branch associated with HEAD (or the lack thereof, for a detached HEAD).
See commit 51ff0f2 by Junio C Hamano (gitster):
log
: decorateHEAD
with branch nameCurrently, log decorations do not indicate which branch is checked out and whether
HEAD
is detached.When branch
foo
is checked out, change the "HEAD, foo
" part of the decorations to "HEAD -> foo
". This serves to indicate both ref decorations (helped by the spacing) as well as their relationshsip.As a consequence, "
HEAD
" without any "->
" denotes a detachedHEAD
now.
This means the 2.4 release notes now include the following Backward compatibility warning(s):
Output from "
git log --decorate
" (and "%d
" format specifier used in the userformat "--format=
" parameter "git log
" family of command takes) used to list "HEAD
" just like other tips of branch names, separated with a comma in between. E.g.
$ git log --decorate -1 master
commit bdb0f6788fa5e3cacc4315e9ff318a27b2676ff4 (HEAD, master)
...
This release updates the output slightly when HEAD refers to the tip of a branch whose name is also shown in the output.
The above is shown as:
$ git log --decorate -1 master
commit bdb0f6788fa5e3cacc4315e9ff318a27b2676ff4 (HEAD -> master)
...