1

Title says it all. I am using pygit2 and trying to figure out how to achieve following that I can do using git cli: git remote set-branches origin remote_branch_name

hasanatkazmi
  • 8,041
  • 2
  • 22
  • 18

1 Answers1

1

If might be simpler to set the configuration directly (since pygit2 Remotes has no obvious way to set the fetch URL)
Using Config.set_multivar(name, regex, value):

repo_obj = pygit2.Repository(repopath)
repo_obj.config.set_multivar(
        'remote.origin.fetch',
        '',
        '+refs/heads/remote_branch_name:refs/remotes/myOrigin/remote_branch_name'
    )
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250