Revert: The Safe Public Undo

A real, genuine mistake reached master. Undo it by adding history, never by removing it.

Frank Chen opened a real PR "speeding up" cookie baking — reviewed for code cleanliness, but nobody caught that 250C for 5 minutes would genuinely burn every batch. It merged. It is now part of master's real, permanent history.\n\nOn a shared branch, git reset --hard would be a real disaster: it rewrites history that a teammate might already have pulled, and force-pushing it away is exactly the kind of damage Block 2.6 exists to prevent. git revert is the real, safe alternative — it creates a genuine NEW commit that undoes the change, adding to history instead of erasing it. Nothing anyone else has already pulled is ever invalidated.

Finding the Real Mistake

git log --oneline -- cookies.md
git show <hash>

A real, genuine diff — the exact change that broke things, found directly in real history.

The Safe Undo

git switch -c fix/cookie-baking-temp
git revert <hash>

A real, new commit — "Revert '...'" — that applies the exact inverse of the original real change. The original commit still exists in history; a new one now cancels it out.

Landing It the Normal Way

git switch master
git merge --no-ff fix/cookie-baking-temp -m "Merge pull request: revert cookie baking temp"
git push

Even undoing a mistake goes through the same real, reviewed process as any other change — exactly what this block's own protected-branch hook requires.

git revert <commit>

Creates a real, new commit that applies the exact inverse of a given commit's changes. Confirmed directly in this lab: the original "Speed up cookie baking time" commit still exists in history — a new "Revert ..." commit now cancels its effect.

Corrective history vs. rewritten history

Reverting adds a real, new commit; resetting or force-pushing removes or rewrites real, existing commits. On any branch other people might already have pulled, only corrective history (revert) is genuinely safe.

🔍 Discover the Real Mistake

Find the commit that broke the cookie recipe, and see exactly what it changed.

cd ~/team-recipes && git log --oneline -3 -- cookies.md
cd ~/team-recipes && git show $(git log --format=%H -- cookies.md | sed -n '1p')

student@lab:~$ cd ~/team-recipes && git log --oneline -3 -- cookies.md fd6441b (origin/feature/faster-cookies) Speed up cookie baking time 5997d5c Add serving note to cookie recipe 7451729 Increase butter back to 175g for a richer flavor student@lab:~$ cd ~/team-recipes && git show $(git log --format=%H -- cookies.md | sed -n '1p') commit fd6441bcf2656cfb39f66430c37399289d22c7e3 (origin/feature/faster-cookies) Author: Frank Chen <frank@example.com> Date: Thu Jan 1 17:30:00 2026 +0000 Speed up cookie baking time diff --git a/cookies.md b/cookies.md index 6568d52..9876a85 100644 --- a/cookies.md +++ b/cookies.md @@ -12,6 +12,6 @@ Instructions: 2. Beat in the eggs one at a time. 3. Mix in the flour and chocolate chips. 4. Drop spoonfuls onto a baking sheet. -5. Bake at 190C for 10-12 minutes. +5. Bake at 250C for 5 minutes to save time. Variations: add walnuts, or swap half the chocolate chips for M&Ms.

↩️ Revert It Safely on a Branch

Undo the mistake with a real, new corrective commit — never by rewriting history.

cd ~/team-recipes && git switch -c fix/cookie-baking-temp
cd ~/team-recipes && git revert --no-edit $(git log --format=%H master -- cookies.md | sed -n '1p')
cd ~/team-recipes && tail -3 cookies.md
cd ~/team-recipes && git push -u origin fix/cookie-baking-temp

student@lab:~$ cd ~/team-recipes && git switch -c fix/cookie-baking-temp Switched to a new branch 'fix/cookie-baking-temp' student@lab:~$ cd ~/team-recipes && git revert --no-edit $(git log --format=%H master -- cookies.md | sed -n '1p') [fix/cookie-baking-temp c9ab35e] Revert "Speed up cookie baking time" Date: Mon Aug 24 19:57:38 2026 +0000 1 file changed, 1 insertion(+), 1 deletion(-) student@lab:~$ cd ~/team-recipes && tail -3 cookies.md 5. Bake at 190C for 10-12 minutes. Variations: add walnuts, or swap half the chocolate chips for M&Ms. student@lab:~$ cd ~/team-recipes && git push -u origin fix/cookie-baking-temp Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 372 bytes | 53.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git * [new branch] fix/cookie-baking-temp -> fix/cookie-baking-temp branch 'fix/cookie-baking-temp' set up to track 'origin/fix/cookie-baking-temp'.

🔗 Land the Fix the Normal Way

Even undoing a mistake goes through the same real, reviewed process.

cd ~/team-recipes && git switch master
cd ~/team-recipes && git merge --no-ff fix/cookie-baking-temp -m 'Merge pull request: revert cookie baking temp'
cd ~/team-recipes && git push
cd ~/team-recipes && git branch -d fix/cookie-baking-temp
cd ~/team-recipes && git push origin --delete fix/cookie-baking-temp

student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is up to date with 'origin/master'. student@lab:~$ cd ~/team-recipes && git merge --no-ff fix/cookie-baking-temp -m 'Merge pull request: revert cookie baking temp' Merge made by the 'ort' strategy. cookies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) student@lab:~$ cd ~/team-recipes && git push Enumerating objects: 1, done. Counting objects: 100% (1/1), done. Writing objects: 100% (1/1), 236 bytes | 59.00 KiB/s, done. Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git 2ab3e7b..428b208 master -> master student@lab:~$ cd ~/team-recipes && git branch -d fix/cookie-baking-temp Deleted branch fix/cookie-baking-temp (was c9ab35e). student@lab:~$ cd ~/team-recipes && git push origin --delete fix/cookie-baking-temp To ../recipes-origin.git - [deleted] fix/cookie-baking-temp

Lab 2.6.1 complete. A real, genuine mistake, safely undone with corrective history:\n\n\n Mistake found in real history : ✅ git show\n Safely reverted on a branch : ✅ git revert\n Landed the normal, reviewed way: ✅ merge --no-ff\n

Enable JavaScript to run the live terminal and track your progress.