Skip to Content
Navigation:

A stick figure smiling

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!

Image of a comic. To read the full HTML alt text, click "read the transcript". get the zine!
read the transcript!

git is CONSTANTLY showing you diffs

smiling stick figure with short curly hair: git show COMMIT_ID

git, represented by a box with a smiley face: here’s the diff!

and it makes it seem like git thinks in terms of diffs

have you ever noticed your git diffs don’t make sense?

git: deleted...
added...

person: but I didn’t DELETE that file, I MOVED it

in git, moving a file is the same as deleting the old one and adding the new one

git mv old.py new.py

is the same as

cp old.py new.py
git rm old.py
git add new.py

git is just guessing about your intentions

person:

git mv old.py new.py
git commit

git: well the OLD version has old.py and the NEW version has new.py and they have the same contents… so I guess you moved it

diff is an algorithm

the algorithm:

  • takes 2 versions of the code
  • compares them
  • tries to summarize it in a human readable way

(but it doesn’t always do a great job)

git has many diff algorithms

person: I’ve been trying out histogram because I don’t like how the default algorithm displays the diff when I rearrange code

how to try it out:
git diff --histogram