Frequently Asked Question
Are commits snapshots or diffs?
Commits in Git are snapshots, not diffs. Each commit stores a reference to a tree object that fully describes the entire project at that point, every directory, every file, with its mode and contents. Inside the object database, file contents are stored as blob objects, deduplicated by hash, so two commits that share an unchanged file both point to the same blob. There is no diff stored anywhere on disk.
What you usually look at, git log -p, GitHub's commit view, the patch that arrives
in your inbox, is a diff computed on the fly by comparing a commit's tree against
its parent's tree. That distinction matters because operations like cherry-pick,
rebase, and merge work by computing those diffs and reapplying them, and they
sometimes notice things (renames, identical content moves) that a literal stored diff
would miss. The snapshot model also makes branching and switching cheap: Git just
changes which tree it materialises in your working directory.