Last Updated: May 1, 2025
Manual Bisect
git bisect startBegin a bisect session
git bisect bad HEADMark current commit as bad (has the bug)
git bisect good v1.0Mark a known-good commit as bug-free
git bisect goodMark currently checked-out commit as good
git bisect badMark currently checked-out commit as bad
git bisect resetEnd bisect and return to original branch
git bisect logShow all steps taken so far
git bisect visualizeOpen gitk to see remaining suspect commits
Automated Bisect
git bisect run ./test.shAuto-bisect: script exits 0=good, 1-127=bad
git bisect run npm testRun test suite automatically on each step
git bisect run python -m pytest test_bug.pyTarget a specific test
git bisect run sh -c 'make && ./test'Build then test at each step
git bisect run ~/bisect-script.shUse a saved script for complex checks
git bisect skipSkip a commit that can't be tested (broken build)
git bisect replay logfileReplay a previous bisect from its log
Bisect Strategy
| Item | Description |
|---|---|
Mark Range First | Always start by marking one good and one bad commit |
Skip Untestable | Use skip for commits that don't compile or have unrelated failures |
Test One Behavior | Bisect for one bug at a time — don't mix issues |
Write a Script | For anything beyond 10 commits, automation saves enormous time |
Old Bug, New Branch | Bisect on a fresh branch to avoid interfering with work |
Save the Log | git bisect log > bisect.log — you may need it for documentation |
Blame vs Bisect | git blame tells you who, bisect tells you when |
Terminology Switch | git bisect terms new/old for non-bug scenarios |
Pro Tip: Automate bisect with `git bisect run ./test.sh` — it will find the offending commit in log2(N) steps while you get coffee.