Git Bisect as a Debugging Tool

Find the commit that broke production. The bisect workflow, with examples.

Setup

Setup is three commands. Mark the current broken commit as bad and a known-working commit as good; git bisect binary-searches the range. Recording the bounds explicitly makes later postmortem reconstruction straightforward.

Test each

Testing each midpoint can be manual (you mark good or bad after each checkout) or automated (a script returns the verdict). Automated bisect wins when the test is scriptable; the convergence happens at machine speed.

Finish

Finishing cleans up the working tree and surfaces the breaking commit. The commit’s diff is usually the bug; the regression test goes into the suite so the bug cannot return.