lin*_*kdd 4 python git libgit2 pygit2
我正在使用pygit2处理非裸存储库
index = repo.index
index.read()
# write in test/test.txt
index.add('test/test.txt')
treeid = index.write_tree()
repo.create_commit(
'HEAD',
author, committer,
'test commit',
treeid,
[repo.head.oid]
)
Run Code Online (Sandbox Code Playgroud)
这很成功,但是当我执行时git status,我得到了这个:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: test/test.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test/
Run Code Online (Sandbox Code Playgroud)
git reset --hard一切之后,一切都得到了解决.
有没有办法用pygit正确更新索引?
你只是从你的内存索引写出一个树,并保持光盘上的索引不被修改,所以在提交后它处于与你做任何事之前相同的状态.
index.write()如果希望将更改存储在光盘上,则需要写出索引().
| 归档时间: |
|
| 查看次数: |
607 次 |
| 最近记录: |