3 ms·
Git's documentation should somehow prominently teach people that: - Git stores snapshots, not changes. - Snapshots go into something called an index. "Git add
by kazinator 3y ago
Git's documentation should somehow prominently teach people that:
- Git stores snapshots, not changes.
- Snapshots go into something called an index. "Git add" means to add to an index.
- A new commit is prepared by creating a new index based on the index of the HEAD commit. This new index is the "stage". The index holds a complete copy of the files. When you stage only certain changes with "git add --patch", that is still the case: you're making a version of the file which has only those selected changes and that goes into the index. A built-in tool that is external to the git representation did the text manipulation to separate those changes.
- When you commit, the uncommitted index you have created as a stage becomes a commit.
- sshine 3y agoThat's a good explanation. I've copied it to a colleague who is learning.