When you create a new repository and run git branch
, it exits silently. For example:
$ mkdir /tmp/foo; cd /tmp/foo; git init
Initialized empty G
No branch heads exist yet.
A Git repository has no branches until you make your first commit. A newly-initialized repository sets HEAD to refs/heads/master, but refs/heads/master won't exist or contain a commit pointer until after the first commit is made.
During a commit, Git dereferences the symbolic-ref HEAD to find the head of the current branch, and then updates that head with the commit hash supplied by git-commit-tree.
The end result is that git branch
has nothing to report in a new repository. With no branch heads present, it simply terminates silently with an exit status of zero.