.git/HEAD
is used by Git to hold the current ref. So when you're on master
, it will be ref: refs/heads/master
. When you are on detached HEAD
, it will be a commit's hash.
.git/refs/remotes/origin/HEAD
is actually a remote ref that points to the default branch on remote. When master is the default remote branch, it will be ref: refs/remotes/origin/master
(if your remote is origin). It's possible to have a default remote branch other than master
but I have noticed that it will not correctly reflect that.
But
$ git remote show github
will always tell you the correct default remote branch.
See this answer of How does origin/HEAD get set? for more details.
git show-ref
shows you refs, which are local branches, remote branches, tags, stash refs.
With
git show-ref HEAD
Git is using the "HEAD" as pattern
git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference]
[-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
[--heads] [--] [<pattern>…]
and only showing refs that match.
See git-show-ref doc.
I mostly use git branch
with -a
or -r
options to see branches, git tag
to see tags, and rarely use git show-ref
.