Skip to content
Latchkey

git bisect: Usage, Options & Common CI Errors

git bisect runs a binary search through your history to pinpoint the commit that broke something.

Bisect turns "somewhere in 500 commits" into ~9 checks. With git bisect run it is fully automatable in CI.

What it does

git bisect checks out commits between a known-good and known-bad point, asking you (or a script) to mark each as good or bad, halving the search range until it finds the first bad commit.

Common usage

Terminal
git bisect start
git bisect bad                    # current commit is broken
git bisect good v1.0.0            # this tag was fine
# ... test each checkout, mark good/bad ...
git bisect run ./test.sh          # fully automated
git bisect reset                  # return to original HEAD

Options

SubcommandWhat it does
startBegin a bisect session
good <rev> / bad <rev>Mark a commit as working / broken
run <cmd>Auto-bisect using a test script exit code
skipSkip an untestable commit
resetEnd bisect and restore HEAD

Common errors in CI

For git bisect run, the test script must exit 0 for good, 1-124/126/127 for bad, and 125 to skip an untestable commit; a non-conforming exit code derails the search. Always finish with git bisect reset, and ensure full history is present (no shallow clone).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →