我正在使用 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]
)
这是成功的,但是当我执行 a 时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/
在 a 之后git reset --hard
,一切都已修复。
有没有办法用 pygit 正确更新索引?