6
我想在分支上进行提交(例如master)。使用pygit2创建提交
我正在使用pygit2
(pygit2.clone_repository
)的仓库克隆
然后我改变现有的文件在库中。
后来我运行此做出承诺:
index = repository.index
index.add_all()
index.write()
author = pygit2.Signature(user_name, user_mail)
commiter = pygit2.Signature(user_name, user_mail)
tree = repository.TreeBuilder().write()
oid = repository.create_commit(reference, author, commiter, message,tree,[repository.head.get_object().hex])
但是当我去到仓库和运行git status
:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: test.txt
修改后的文件似乎是增加了提交,但提交没有成功。使用返回的OID,我可以在pygit2存储库中找到commit属性。
我错过了什么吗?
我没有看到你的代码提到某处的分支,也许你应该指定某处? – 2015-04-06 10:48:45
引用的值是'ref/heads/master' – user1479699 2015-04-06 10:54:10
我很难为pygit2找到体面的文档,所以我只是猜测:我看到在做了一些状态更改后调用了各种'write()'方法。 'create_commit()'是隐式写入还是忘记这么做? – 2015-04-06 10:56:56