[英]Untracked dirs on commit with 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]
)
这是成功的,但是当我执行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/
在git reset --hard
,一切git reset --hard
修复。
有没有办法用pygit正确更新索引?
您只从内存中索引写出一棵树,而未修改磁盘上索引,因此在提交后,它的状态与执行任何操作之前的状态相同。
如果要将更改存储在磁盘上,则需要写出索引( index.write()
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.