4 ms·
You can (for example) modify a file, stage it, then further modify it. You now have three copies of your file - the original, the staged version, and the workin
by ekimekim 9y ago
You can (for example) modify a file, stage it, then further modify it. You now have three copies of your file - the original, the staged version, and the working tree version.
A "git checkout -- file" would revert your working tree copy to your staged copy, whereas a "git checkout HEAD -- file" would revert both your staged copy and your working tree copy to the unmodified copy.
There are other scenarios but this is by far the most common. The index (aka. staged files) can be thought of as a completely seperate copy of your working tree that can have arbitrary changes written to it independent of the working tree. It's just that in normal usage you're only ever copying to the index (via git add) FROM your working tree.