Untracked channels on commit with pygit2

I am working on a non-bare repository with 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] ) 

This is successful, but when I execute git status , I got the following:

 # 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/ 

And after a git reset --hard everything is fixed.

Is there a way to properly update the index using pygit?

+4
source share
1 answer

You only write a tree from your index in memory and leave the index without a disk unchanged, so after fixing it is in the same state as before you did anything.

You need to write the index ( index.write() ) if you want your changes to be saved to disk.

+6
source

All Articles