Something works at commit v1.0 and is broken at HEAD. Somewhere in between, a commit introduced the bug. git bisect finds it in roughly log₂(N) steps — 1000 commits in about 10 checks.
The session works like a guided binary search:
git bisect start — begin.
git bisect bad — tell Git the current commit is broken.
git bisect good <old-hash> — give it a commit you know was working.
- Git checks out the midpoint commit. Test it. Run
git bisect good or git bisect bad based on the result.
- Git picks the next midpoint. Repeat until it prints "<hash> is the first bad commit".
git bisect reset returns you to your original branch.
For repeatable tests, automate the whole loop: git bisect run ./test.sh. Git keeps marking good/bad based on the script's exit code until it lands on the culprit.