Revert

Reset rewrites history by moving a pointer backwards. That is fine for work only you have — and a problem once others have the commits, because their history no longer matches yours.

Revert undoes a commit by adding a new one that cancels it out. Nothing is rewritten, the original stays in the history, and the undo itself is recorded.

Reset for private mistakes; revert for public ones.

Exercises

  1. Exercise 1. c1 broke something, but it has already been shared — so rewriting history is not an option. Revert it instead.
  2. Exercise 2. The bad commit is c1, but c2 came after it and is fine. Revert only c1 — the new commit still lands on the tip, where your work is.