How to get the current checked out Git branch name through pygit2?
This question should be related to:
But I am wondering how to do that through pygit2?
From PyGit Documentation
Either of these should work
head = repo.lookup_reference('HEAD').resolve()
head = repo.head
branch_name = head.name
要获得传统的“速记”名称:
from pygit2 import Repository
Repository('.').head.shorthand # 'master'
链接地址: http://www.djcxy.com/p/19502.html
上一篇: git仅为当前分支提取