我想要执行
git remote add -f origin <repo>
在gitpython中知道某人是解决方案还是替代方案?
感谢您的想法。
答案 0 :(得分:1)
在Dulwich master 中,您可以使用dulwich.porcelain.remote_add方法:
from dulwich import porcelain
porcelain.remote_add('origin', 'http://github.com/git/git')
在旧版本(没有porcelain.remote_add)中,您可以使用以下内容:
from dulwich.repo import Repo
c = Repo('.').get_config()
c.set(('remote "origin"', ), "url", "http://github.com/git/git")
c.write_to_path()