← Winnitude! Search  ·  Reader Mode (784 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 12 LINKS

How to run set-branches · gitpython-developers/GitPython · Discussion #1386

Repository navigation

How to run set-branches #1386

Unanswered dsharma522 asked this question in Q&A How to run set-branches #1386 dsharma522 Dec 20, 2021 · 1 comment Return to top Discussion options

dsharma522 Dec 20, 2021

what will be the equivalent of git remote set-branches origin --add master8 in GitPython?

Is it repo.git.remote('set-branches', 'origin', '--add', 'master4')

1 You must be logged in to vote

Replies: 1 comment

Comment options

briantoby Jun 22, 2024

yes (except for the discrepancy between master4 and master8 above), but as I understand things this is only needed after a shallow clone (using --depth).

This code snippet shows a way to make all branches available locally:

import git
repo = git.Repo('/tmp/g2')
repo.git.remote('set-branches','origin','*')
repo.git.fetch()
branchlist = [i.strip() for i in repo.git.branch('-r').split('\n') if '->' not in i]
0 You must be logged in to vote 0 replies Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment Category Q&A Labels None yet 2 participants