pygit2:如何“git remote setbranches origin remote\u branch\u name”

2024-04-29 14:11:20 发布

您现在位置:Python中文网/ 问答频道 /正文

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


Tags: namegitbranch标题目标cliremotepygit2
1条回答
网友
1楼 · 发布于 2024-04-29 14:11:20

If可能比直接set the configuration更简单(因为pygit2 Remotes没有明显的方式来设置获取URL)
使用^{}

repo_obj = pygit2.Repository(repopath)
repo_obj.config.set_multivar(
        'remote.origin.fetch',
        '',
        '+refs/heads/remote_branch_name:refs/remotes/myOrigin/remote_branch_name'
    )

相关问题 更多 >