Hacker News new | ask | show | jobs
by ndand 1903 days ago
I used to think commits as snapshots, but it was confusing. Then I read "Git Internals".

A commit contain the "whole" content of each file that we've commited. But since a commit has a pointer to a root commit, it also represents a working directory. Even though a commit contain "whole" files, the git internally stores only parts of the files as an optimization.

When we diff two commits, we see the difference of the file contents in the corresponding working directories that the commits represent.