pygit2:如何“ git远程设置分支起源remote_branch_name”

时间:2020-06-18 02:35:52

标签: python git pygit2

标题说明了一切。我正在使用pygit2并试图弄清楚如何使用git cli可以实现以下目标: git remote set-branches origin remote_branch_name

1 个答案:

答案 0 :(得分:1)

如果直接使用set the configuration可能更简单(因为pygit2 Remotes没有设置获取网址的明显方法)
使用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'
    )