Theory
Theory: Bisect is Binary Search on First-Parent History
If a test can label a commit good or bad, git bisect finds the first bad commit in O(log N) checkouts.
Invariants
- You mark an old good and a current bad; Git checks out the midpoint.
git bisect run ./test.shautomates the oracle.- Skip unbuildable commits; they are not evidence.
- The answer is a commit hash, not a file.
G G G G B B B B (good/bad along a chain)
^ first bad
What can break
- A flaky test (non-monotonic good/bad).
- Bisecting a merge-heavy history without understanding first-parent.
How to read this chapter
Manual bisect, automate with tests, 2 AM story, lab.