git bisect uses binary search to find the commit that introduced a bug — even in a repo with thousands of commits:
git bisect start
git bisect bad # current commit is broken
git bisect good v1.0.0 # last known good state
# Git checks out a commit halfway between good and bad
# Test it — is it broken?
git bisect bad # yes, still broken → bug is before this
git bisect good # no, it's fine → bug is after this
# Repeat until Git finds the exact commit
# Then end the bisect session
git bisect reset # go back to original branch
# If you have a script that returns 0 (good) or 1 (bad):
git bisect run bash test.sh
Use git bisect run to find the bad commit automatically. The test script checks if value.txt contains good. The result should be stored in BAD_COMMIT.
Click "Run" to execute your code.