I'm trying to understand how the git index file works.
I have a local repository with some files, one of them test.txt
. I was on commit X
and saved the index file of that commit to a temp directory.
Then I edited test.txt
added and committed it which created commit Y
. After that I ran git reset --hard X
and saved the index file of commit X
after having reset to it from commit Y
.
Then I compared both index files (from commit X
and from commit X
after having reset to it from commit Y
) and they were not identical. How can this be ? Is there a timestamp in the file ? as far as I know the index should have been reset to its previous contents (?)
What does it matter what the index file is like? All that's important is what version of what files it lists. You can find that out with
ls-files
.Example:
OK, so those are the "contents" of the index. Now let's make a change and a new commit:
And now let's reset:
As you can see, the index is "identical" to what it was, in the only sense that matters.