Python 如何向索引中添加一些内容,提交它,然后使用dulwich将主分支推送到一个命名的remote?
如何向索引中添加内容,如中所示Python 如何向索引中添加一些内容,提交它,然后使用dulwich将主分支推送到一个命名的remote?,python,git,dulwich,Python,Git,Dulwich,如何向索引中添加内容,如中所示 git add . 然后 然后 用德威治 到目前为止,我已经找到了这个,但它没有说太多,是吗 谢谢在这种情况下,您不需要指数,只需要回购(指数是其中的一部分) 像这样的方法应该会奏效: >>> from dulwich.repo import Repo >>> x = Repo('.') >>> x.stage(['a']) >>> x.do_commit(message="foo") '1
git add .
然后
然后
用德威治
到目前为止,我已经找到了这个,但它没有说太多,是吗
谢谢在这种情况下,您不需要指数,只需要回购(指数是其中的一部分) 像这样的方法应该会奏效:
>>> from dulwich.repo import Repo
>>> x = Repo('.')
>>> x.stage(['a'])
>>> x.do_commit(message="foo")
'151915d47467696d2f9d18de6f61be7168682aeb'
这不是一个经过测试的答案,但更接近推送部分:
# set wants to master
def wantmaster(haves, wants):
global repo
return { "refs/heads/master": repo.refs["HEAD"] }
client, src = dulwich.client.get_transport_and_path(origin_uri)
client.send_pack(src, wantmaster, repo.object_store.generate_pack_contents)
我的代码中有一个变体正在工作。如何添加所有内容并提交它们?我测试了您的代码,但提交似乎是空的…没有添加任何文件
>>> from dulwich.repo import Repo
>>> x = Repo('.')
>>> x.stage(['a'])
>>> x.do_commit(message="foo")
'151915d47467696d2f9d18de6f61be7168682aeb'
# set wants to master
def wantmaster(haves, wants):
global repo
return { "refs/heads/master": repo.refs["HEAD"] }
client, src = dulwich.client.get_transport_and_path(origin_uri)
client.send_pack(src, wantmaster, repo.object_store.generate_pack_contents)