
Here's a preview from my zine, How Git Works! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

read the transcript!
commits never change
once you’ve made a commit, it’s set in stone: - the files in it never change - its diff never changes - its history never changes - the message/author never change
commit hashes
commits never change because their ID is calculated from their contents.
Illustration of a box labelled sha1 hash
.
Going into the box are: - every file - parent(s) - message - author - timestamp
Coming out of the box is an arrow labelled 3530a42
.
you can think of commits as a pile of diffs
Illustration of a stack of boxes connected with lines. Each box is labelled “diff”, except for the bottom one, which is labelled “START”. The top box has an arrow pointing to it that says “current”.
if you combine all the diffs together, you’ll get the current state of the project!
(not how Git works, but a VERY useful way to think about commits!)
you can also think of commits as a pile of snapshots
Illustration of a stack of boxes connected with lines. Each box is labelled “snapshot”, except for the bottom one, which is labelled “START”. The top box has an arrow pointing to it that says “current”.
this is how Git is implemented!
confused bald stick figure: is git saving a NEW copy, EVERY TIME?? happy stick figure with curly hair: not quite! it has some tricks! (on the next page)
diffs are calculated from snapshots
Illustration of two boxes, one on top of the other, connected with lines. Both boxes are labelled “snapshot”.
the diff is the difference between a commit and its parent
happy stick figure with curly hair: hey what’s the diff for 353ea42
?
git, represented by a box with a smiley face: let me calculate that REALLY FAST!
things git can do with a commit
- get the files in the commit (like
git checkout
) - calculate the diff from its parent (like
git show
) - merge if with arother commit (like
git merge
) - look at its parents, grandparents, etc (like
git log
)
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!