Library
Softwarebeginner3 min readNov 24, 2026
Bisecting a Regression Properly
Turn a vague 'it broke recently' into a single guilty commit using git bisect and a reliable check.
The prerequisite
Bisection is only as good as your pass/fail check. Write a script that exits 0 on good and non-zero on bad, and confirm it distinguishes both endpoints.
Automate it
git bisect start
git bisect bad HEAD
git bisect good v1.4.0
git bisect run ./check.sh
Git narrows the range logarithmically. Twenty commits take five iterations.
Handle build flakes
If a commit fails to build for unrelated reasons, exit 125 from the script. Bisect skips it instead of recording a false result.
Read the result critically
The reported commit is the first bad one in that linear history. Merge commits can hide the real change — inspect the merge diff and, if needed, bisect within the branch.
Close the loop
Add a regression test derived from check.sh, then revert or fix. A bisect that ends without a test tends to be repeated.