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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Running
git branch -adoesn’t listHEAD. In libgit2,HEADisn’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
HEADreference (try thegit_repository_head()convenience method)git_reference_type())GIT_REFERENCE_SYMBOLICorGIT_REFERENCE_DIRECT) retrieve one of the followinggit_reference_symbolic_target())git_reference_target())