Gitpython: Can't list remote branches

Created on 23 May 2017  路  4Comments  路  Source: gitpython-developers/GitPython

repo = git.Repo("...") // Directory that already has a cloned repository
repo.heads
[]

The repository has a whole bunch of remote branches but I only see the local one. Any way of getting a list of all remote branches?

Q&A

Most helpful comment

You can access remote refs via repo.remotes.origin.refs. You will find more code in context by search for refs in the tutorial.

All 4 comments

I have same issue

You can access remote refs via repo.remotes.origin.refs. You will find more code in context by search for refs in the tutorial.

    data = Git().execute('git ls-remote -h git_url')
    branches = [ x.split('/')[-1] for x in data.split('\n') ]

GitPython 3.1.2 and this still doesn't work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niso120b picture niso120b  路  4Comments

cool-RR picture cool-RR  路  4Comments

tucked picture tucked  路  5Comments

catskul picture catskul  路  5Comments

theyonibomber picture theyonibomber  路  5Comments