Running git branch -a does not display HEAD . In libgit2, HEAD not considered a valid branch. This is just a link .
If you want to know which link is the current branch, then you should
- Download the current
HEAD link (try the git_repository_head() method) - Define its type (using
git_reference_type() ) - Depending on its type (
GIT_REF_SYMBOLIC or GIT_REF_OID ), select one of the following- Branch name (using
git_reference_symbolic_target() ) - The
git_reference_target() pointed to (using git_reference_target() )
source share