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 has no undo

there’s no

  • unadd
  • uncommit
  • unmerge
  • unrebase

instead, git has a single dangerous command for undoing: git reset

most git commands move the current branch forwards

  • git commit
    Illustration of three boxes in a row, connected by lines. There is an arrow pointing from the second box to the third box.
  • git merge Illustration of two boxes in a row, connected by lines. From the second box, two lines diverge to two other boxes, and from those two, lines converge back into a final box. There is an arrow pointing from one of the diverged boxes into the final merged box.
  • git pull
    Illustration of five boxes in a row, connected by lines. There is an arrow pointing from the second box to the fifth box.

(though rebase is a sideways move)

git reset can move the current branch anywhere

  • backwards!
  • forwards!
  • “sideways”!

Illustration of five boxes, connected with lines into two branches, with arrows pointing in all directions amongst them.

this makes it possible to undo, but you can also really mess up your branch

how git reset works

git reset HEAD^

  1. finds the commit ID corresponding to HEAD^ (for example a2b3c4)
  2. forces your current branch to point to a2b3c4
  3. unstages all changes

--hard: the danger option

git reset $COMMIT_ID
Keeps all the files in your working directory exactly the same.

git reset --hard $COMMIT_ID
Throws away all your uncommitted changes. Useful but dangerous.

problems reset can cause

  • (sad face) it’s easy to “lose” commits, especially if you move a branch backwards
  • (sad face) if you use --hard, you can permanently lose your uncommitted changes

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2025 | All rights reserved (see the FAQ for notes about licensing)