Skip to content

Get Active Branch #945

Answered by jelmer
dufferzafar asked this question in Q&A
Dec 26, 2017 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Try something like:

 >>> from dulwich.repo import Repo
 >>> Repo('.').refs.follow(b'HEAD')
 (['HEAD', 'refs/heads/master'], '4349a6e7e86d3566678657dfe4719b8a026293d9')

or more specifically:

>>> Repo('.').refs.follow(b'HEAD')[0][-1].lstrip(b'refs/heads/')
'master'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jelmer
Comment options

Answer selected by jelmer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #596 on February 17, 2022 19:55.