Reputation: 1387
I have been reading What's the deal with the git index but can someone explain me why a file stays in the index after it has been committed. I don't see why this is necessary...
Upvotes: 3
Views: 520
Reputation: 62369
Another way to think of it is that the index always holds what would be the contents of the next commit if you did a git commit
. So, immediately after a commit, it should contain exactly the contents of that commit. As you make further modifications, you add those to the index to craft your next commit.
Upvotes: 0
Reputation: 125139
Firstly, it helps to note that Git stores your repository history in terms of snapshots, not patches.
So, when you run git status
and see that you have no staged changes, this does not mean the index is "empty".
It means there is no difference between the snapshot that is in the index, and the latest commit (more accurately, the commit referenced by HEAD
).
Upvotes: 3