I want a list of all my branches from a repository from github. so i can do something like this.
print(branches[1])
and ill get an output of a branch name. I haven't found a straight answer on how to do this.
import subprocess
subprocess.check_output(['git', 'branch']).decode().split('\n')
Another possibility:
from pygit2 import Repository
repo = Repository(path_to_your_repo) # use '.' if you are already there
repo.branches
g = Github("key")
repo = g.get_repo("link to repo")
versions = []
for branch in repo.get_branches():
versions.append(branch.name)