how to run set-branches at origin in GitPython

149 Views Asked by At

I am working with shallow-clone and shallow fetch with GIT repo, There is Git-Python being used in the code

In Git-python, what would be equivalent command for the following git cmd command git remote set-branches origin --add master8

I read their docs, but couldn't make it work. Any help is appreciated.

Relevant code

repo = git.Repo('Demo1')
repo.remotes.origin.fetch('+refs/heads/master2:refs/remotes/origin/master2', depth=1)
'git remote set-branches origin --add  master2' # need to run this
# repo.git.remote('set-branches', 'origin', '--add', 'master2')
repo.git.checkout('master2')
repo.git.reset('--hard', f'origin/master2')
repo.git.clean('-dfx')
repo.remotes.origin.pull(depth=1)
0

There are 0 best solutions below