python - pygit2:如何“git remote set-branches origin remote_branch_name”
问题描述
标题说明了一切。我正在使用pygit2
并试图弄清楚如何使用 git cli 实现以下操作:
git remote set-branches origin remote_branch_name
解决方案
如果直接设置配置可能更简单(因为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'
)
推荐阅读
- python - 矩形晶格适合噪声坐标
- ios - 如何使用标签文本 (Int) 值编写 if 条件
- python-3.x - 如何在熊猫中选择每个唯一记录的最后 5 行
- ios - QR 扫描仪 URL 字符串到 WKWebView
- similarity - 有没有办法在相似函数中组合多个距离度量?
- java - Java Excel Api 字符编码问题
- discord - Discord ID(ulong 编号)是可接受的身份验证形式吗?
- r - 从 Date 到 POSIXct 对象的转换 - 错误一小时
- .net - SagePay 直接集成套件 v4.00
- google-apps-script - 如何为 Smartsheet 生成重定向 URI 以将数据传递到 Apps 脚本