Git Bisect: Binary Search for Bugs
check-times.sh started failing. Somewhere in the last 50 commits, one of them broke it.
check-times.sh is a real, small script that validates every recipe file states a genuine, numeric cook time. It has been passing for a long time. Right now, on the current real HEAD, it genuinely fails — and fifty ordinary-looking "add a recipe" commits have landed since the last time anyone checked.\n\nReading fifty real diffs by hand would work eventually. git bisect does the same job with a real binary search instead: pick a commit roughly halfway between the last known-good point and now, test it, and the answer to that ONE test cuts the real search space in half every single time. Fifty commits takes six real rounds, not fifty.
The Real Problem
sh check-times.sh
# BAD: recipe-33.md (Cook time: 'quick')
Something, somewhere in the last 50 real commits, left a recipe file with a genuinely non-numeric cook time. The current failure tells you THAT it's broken — not which of the 50 commits did it.
A Real Binary Search, Not Fifty Diffs
git bisect start HEAD HEAD~50
# git checks out a real commit roughly halfway between the two
sh check-times.sh # test THIS commit
git bisect good # or: git bisect bad
Each real answer — good or bad — halves the remaining search space. git checks out the new midpoint automatically and waits for the next real answer.
Landing on the Real Answer
git bisect bad
# a491a83 is the first bad commit
git bisect reset
Once only one commit remains, git names it directly. git bisect reset returns you to your real branch, exactly where you started — bisect never changes your branch's actual history, only what's checked out while you search.
git bisect
A real binary search over a range of commits, driven by your own real good/bad judgment at each step. Confirmed directly in this lab: 50 real commits took exactly 6 real rounds to narrow down to one.
git bisect reset
Returns you to the real branch and commit you started from before the bisect began. Confirmed directly in this lab: bisect leaves your actual branch pointer untouched the entire time — only the checked-out commit moves while you search.
🚨 Something Is Genuinely Wrong
check-times.sh, passing for a long time, fails right now on the current real HEAD.
cd ~/team-recipes && sh check-times.shstudent@lab:~$ cd ~/team-recipes && sh check-times.sh BAD: recipe-33.md (Cook time: 'quick')
🎯 Start the Real Bisect
Tell git the real boundaries: HEAD is bad, 50 commits back is known good.
cd ~/team-recipes && git bisect start HEAD HEAD~50student@lab:~$ cd ~/team-recipes && git bisect start HEAD HEAD~50 Bisecting: 24 revisions left to test after this (roughly 5 steps) [79d72304736f7169ad90cb021a36b709397d629d] Add recipe: Smoky Salsa
🔬 Six Real Rounds
Test the checked-out commit, report good or bad, and let git narrow it down.
cd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect goodcd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect badcd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect goodcd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect badcd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect badcd ~/team-recipes && sh check-times.shcd ~/team-recipes && git bisect goodstudent@lab:~$ cd ~/team-recipes && sh check-times.sh All recipes OK student@lab:~$ cd ~/team-recipes && git bisect good Bisecting: 12 revisions left to test after this (roughly 4 steps) [6d60f8e276ca504bcc05a9f899f3d12a69c01274] Add recipe: Fiery Bowl student@lab:~$ cd ~/team-recipes && sh check-times.sh BAD: recipe-33.md (Cook time: 'quick') student@lab:~$ cd ~/team-recipes && git bisect bad Bisecting: 5 revisions left to test after this (roughly 3 steps) [490b96562c8e22488d156a6ae0330833b035003f] Add recipe: Grilled Casserole student@lab:~$ cd ~/team-recipes && sh check-times.sh All recipes OK student@lab:~$ cd ~/team-recipes && git bisect good Bisecting: 2 revisions left to test after this (roughly 2 steps) [3ce17b8dad10c5e19619af42fb6f7c670e45f599] Add recipe: Sweet Chili student@lab:~$ cd ~/team-recipes && sh check-times.sh BAD: recipe-33.md (Cook time: 'quick') student@lab:~$ cd ~/team-recipes && git bisect bad Bisecting: 0 revisions left to test after this (roughly 1 step) [cb72f521d32f5c857685b780a41995e895041eb2] Add recipe: Chilled Frittata student@lab:~$ cd ~/team-recipes && sh check-times.sh BAD: recipe-33.md (Cook time: 'quick') student@lab:~$ cd ~/team-recipes && git bisect bad Bisecting: 0 revisions left to test after this (roughly 0 steps) [38c2218dee30e7705a0b2e75eec9d0a7ae65b5c1] Add recipe: Baked Dip student@lab:~$ cd ~/team-recipes && sh check-times.sh All recipes OK student@lab:~$ cd ~/team-recipes && git bisect good cb72f521d32f5c857685b780a41995e895041eb2 is the first bad commit commit cb72f521d32f5c857685b780a41995e895041eb2 Author: Ada Lovelace <ada@example.com> Date: Fri Jan 2 08:40:00 2026 +0000 Add recipe: Chilled Frittata recipe-33.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 recipe-33.md
🩹 Reset and Fix It Forward
Return to the real branch, then land a genuine fix for what bisect found.
cd ~/team-recipes && git bisect resetcd ~/team-recipes && cat recipe-33.mdcd ~/team-recipes && sed -i 's/Cook time: quick minutes\./Cook time: 25 minutes./' recipe-33.mdcd ~/team-recipes && git add recipe-33.mdcd ~/team-recipes && git commit -m 'Fix invalid cook time in recipe-33.md (found via git bisect)'cd ~/team-recipes && sh check-times.shstudent@lab:~$ cd ~/team-recipes && git bisect reset Previous HEAD position was 38c2218 Add recipe: Baked Dip Switched to branch 'master' Your branch is ahead of 'origin/master' by 56 commits. (use "git push" to publish your local commits) student@lab:~$ cd ~/team-recipes && cat recipe-33.md Recipe: Chilled Frittata Cook time: quick minutes. student@lab:~$ cd ~/team-recipes && sed -i 's/Cook time: quick minutes\./Cook time: 25 minutes./' recipe-33.md student@lab:~$ cd ~/team-recipes && git add recipe-33.md student@lab:~$ cd ~/team-recipes && git commit -m 'Fix invalid cook time in recipe-33.md (found via git bisect)' [master c900275] Fix invalid cook time in recipe-33.md (found via git bisect) 1 file changed, 1 insertion(+), 1 deletion(-) student@lab:~$ cd ~/team-recipes && sh check-times.sh All recipes OK
Lab 3.3.1 complete. A real regression, hidden among 50 ordinary commits, found by hand in six real steps:\n\n\n check-times.sh failing : ✅ confirmed on real HEAD\n git bisect start/good/bad: ✅ 6 real rounds\n Exact commit found : ✅ recipe-33.md\n Fixed forward : ✅ check passes again\n
Enable JavaScript to run the live terminal and track your progress.