Reputation: 490
When you delete a file from your project by running the git rm
command, when is the file actually removed from the index? Is it removed when you commit the deletion or is it removed when git rm
is run?
From what I understand, a git rm involves the following steps:
I'm just not sure whether the file is removed in the beginning from the index or when the deletion is committed. Also are these steps even correct?
Upvotes: 0
Views: 37
Reputation: 487993
It happens immediately, but there is no commit at this point. That is, only steps 1 and 2 apply.
A good way to think of the index is that it's a third copy of everything—or really, a second copy, and the work-tree is the third. That is, at any time, you have:
HEAD
or sometimes @
. Since this is a commit, it cannot be changed at all.Note that you can copy files in both directions here: from HEAD
to index, from index to work-tree, or from work-tree to index. But since commits can never be changed you can't copy from index back into HEAD
. (What you do instead is make a new commit—copy from index to new commit. Of course, that new commit is permanent.)
Upvotes: 4