【问题标题】:pygit2: How to "git remote set-branches origin remote_branch_name"pygit2:如何“git remote set-branches origin remote_branch_name”
【发布时间】:2020-10-08 00:07:55
【问题描述】:

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

【问题讨论】:

    标签: python git pygit2


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2023-02-22
      • 2017-09-12
      • 2014-03-05
      • 2015-01-20
      • 2018-10-05
      • 2011-02-10
      • 1970-01-01
      • 2015-10-03
      • 2019-06-23
      相关资源
      最近更新 更多