$ Git Game

Undo a commit that's on main

The commit is pushed, so other clones may have it already. The undo has to be something they can pull: a new commit that takes the change back.

Revert: a commit that undoes a commit

$ git revert --no-edit HEAD
[main 3132ca8] Revert "api: handle the edge case"
 Date: Sun Oct 4 12:03:00 2026 +0000
 1 file changed, 1 deletion(-)
$ git log --oneline
3132ca8 Revert "api: handle the edge case"
bc13ce9 api: handle the edge case
ab5768d api: the first endpoint
07dec17 readme: the project
$ git push
To ../origin.git
   bc13ce9..3132ca8  main -> main

git revert HEAD makes a new commit with the inverse change, named after the one it undoes, and leaves the history as it was. The push is a fast-forward, and everyone's next pull brings the fix. To revert a merge commit, add -m 1: which of its parents counts as the line you are staying on.

Why not a reset

$ git reset --hard HEAD~1
HEAD is now at ab5768d api: the first endpoint
$ git push
To ../origin.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to '../origin.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git push --force
To ../origin.git
 + bc13ce9...ab5768d main -> main (forced update)

git reset --hard HEAD~1 takes the commit off your main, but the remote's main still has it, and a push that would move main backwards is rejected. --force makes the remote take it, and now the commit is erased from main for everyone, with every other clone diverged: the forced update page's situation. On a branch nobody else has pulled, that is fine. On main, revert.

Not pushed yet

If the commit never left your clone there is nobody to tell. git reset --soft HEAD~1 takes it back and keeps its changes staged (on the lost commit page), and git commit --amend rewrites it in place.

Why the game does this to you

In Git Game the revert card does what Git's does: put on a face-up bug on main, it no longer counts as a bug at the release, and the commit stays where it is. The only card that takes a commit off main is push --force, with its sin token, which is Git's lesson in a card.

Play a day where this happens

One tap starts a game against the bot. Twelve bugs in sixty cards; one of them will be yours.

play the bot now

Output captured from Git 2.50.1 (Apple Git-155) by scripts/git-output.sh, in a scratch repository with two clones, ana's and bot's, and fixed dates, so the hashes are the same on every run. It is captured again at every Git release.