You're only writing out a tree from your in-memory index and leaving the on-disc index unmodified, so after the commit it is at the same state as it was before you did anything.
You need to write out the index (index.write()
) if you want your changes to be stored on disc.