I am trying to use libgit2 to read the name of the current branch. Do I have to do some sort of resolve?
I tried using
git_branch_lookup
to look up the git_reference
for HEAD
, but it results in
Unable to find local branch 'HEAD'
Thanks!
Running git branch -a
doesn't list HEAD
. In libgit2, HEAD
isn't considered a valid branch either. It's only a reference.
If you want to discover which reference is the current branch, then you should
HEAD
reference (try the git_repository_head()
convenience method)git_reference_type()
)GIT_REF_SYMBOLIC
or GIT_REF_OID
) retrieve one of the following
git_reference_symbolic_target()
) git_reference_target()
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With