1. A commit is a photo, not a list of changes
A commit is a complete snapshot of every file; unchanged files are links to copies Git already has; the changes you see are computed by comparing two snapshots.
Almost every Git surprise comes from picturing a list of patches. Picture photos and the rest of the series follows.
Most people picture Git as a list of changes. Add this line. Remove that one.
That is not what Git stores. A commit is a photo of every file in the project. All of them, at once.
Three commits are three photos. Each one is complete on its own.
A file that did not change is not copied again. The new photo points at the copy it already has.
When Git shows you a change, it compares two photos. The change is worked out on the spot. The photo is what is stored.
Check yourself. Git shows you a one-line change between two commits. What does Git actually store: the change, or the two photos?
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime