[英]How to add something to the index, commit it, then push the master branch to a named remote with dulwich?
我如何在索引中添加一些內容,例如
git add .
然后
git commit -m "message"
然后
git push origin master
使用德威?
到目前為止,我已經找到了這個http://www.samba.org/~jelmer/dulwich/apidocs/dulwich.index.Index.html,但它並沒有說明太多,是嗎?
謝謝
這不是一個經過測試的答案,但在推送部分更接近:
# 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)
在我的代碼中對此有所變化。
在這種情況下,您不希望索引,而需要存儲庫(索引是其中的一部分)。 http://www.samba.org/~jelmer/dulwich/apidocs/dulwich.repo.Repo.html
這樣的事情應該起作用:
>>> from dulwich.repo import Repo
>>> x = Repo('.')
>>> x.stage(['a'])
>>> x.do_commit(message="foo")
'151915d47467696d2f9d18de6f61be7168682aeb'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.