Forked from igniteflow/git_python_current_branch.py
Last active
November 8, 2022 13:33
-
-
Save Brimizer/8fd44f5e84321b44080e to your computer and use it in GitHub Desktop.
GitPython get current active branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Depends on GitPython | |
pip install GitPython | |
""" | |
from git import Repo | |
def get_current_branch_name(repo_path) | |
""" | |
Gets the name of the active Git branch as a string. | |
""" | |
repo = Repo('/path/to/your/repo') | |
branch = repo.active_branch | |
return branch.name | |
def |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment