Python:dulwich中的git remote add -f origin

时间:2016-01-02 14:45:08

标签: python gitpython dulwich

我想要执行

git remote add -f origin <repo>

与德威有关。但是,我找不到朝这个方向发展的东西。

在gitpython中知道某人是解决方案还是替代方案?

感谢您的想法。

1 个答案:

答案 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()