【问题标题】:Untracked dirs on commit with pygit2使用 pygit2 提交时未跟踪的目录
【发布时间】:2013-04-17 09:44:52
【问题描述】:

我正在使用 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 之后,一切都修复了。

有没有办法用 pygit 正确更新索引?

【问题讨论】:

    标签: python git libgit2 pygit2


    【解决方案1】:

    您只是从内存索引中写出一棵树,而磁盘上的索引保持不变,因此在提交之后它处于与您执行任何操作之前相同的状态。

    如果要将更改存储在磁盘上,则需要写出索引 (index.write())。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 2017-12-30
      • 1970-01-01
      • 1970-01-01
      • 2023-01-05
      • 2017-01-16
      相关资源
      最近更新 更多