Finding Bugs with git bisect

git bisect performs a binary search through commit history to locate the commit that introduced a regression. You mark a known bad commit and a known good commit, and Git repeatedly checks out a midpoint. You test that version and tell Git whether it is good or bad.

Binary Search a Regression
git bisect start
git bisect bad
git bisect good v1.0.0

# test the checked-out commit
git bisect good
# or
git bisect bad

git bisect reset
💡 Git narrows the search range by approximately half after every good/bad classification. Once finished, git bisect reset returns to the original branch.
Key Takeaways
  • Bisect is efficient for locating regressions in large histories.
  • Each classification should accurately reflect whether the tested revision is good or bad.
  • Automated tests can be used with git bisect run.
Knowledge Check

What algorithmic strategy does `git bisect` use?