Home > Enterprise >  How do i get a list of branches from a github repository?
How do i get a list of branches from a github repository?

Time:10-10

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.

CodePudding user response:

import subprocess

subprocess.check_output(['git', 'branch']).decode().split('\n')

CodePudding user response:

You can refer the below mentioned answer for a similar type question.

git branch -r

https://stackoverflow.com/a/3472296/10383509

  • Related