Manuals / Git & GitHub / Chapter 9

C · Recover · advanced · Day 6–7 · Chapter 9 of 12

git bisect — find the breaking commit

Binary search through history. Mark good and bad commits. Git checks out middle. O(log n) instead of manual.

Path progress
69%

Step 1 of 3

Manual bisect

git bisect start. git bisect bad (current broken). git bisect good <old-good-hash>. Test. git bisect good/bad until found.

Manual bisectDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Manual bisectdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

git bisect start
git bisect bad
git bisect good v1.0-tag
# test each checkout
git bisect good   # or bad
git bisect reset   # when done

Do this now

Plant a bug in commit 3 of 8 in practice repo. Bisect to find it.

Was this step clear?
Chapter learning outcomes
  • git bisect start/good/bad
  • Automated bisect run
  • bisect reset

Clear these before you leave

Side quest

Bisect story

Blog-post length note: "How I found the regression in 10 minutes."