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 HEADOptions
| Subcommand | What it does |
|---|---|
| start | Begin a bisect session |
| good <rev> / bad <rev> | Mark a commit as working / broken |
| run <cmd> | Auto-bisect using a test script exit code |
| skip | Skip an untestable commit |
| reset | End 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
git log: Usage, Options & Common CI Errorsgit log shows commit history with flexible formatting. Reference for --oneline, --graph, --pretty, ranges, an…
git reflog: Usage, Options & Common CI Errorsgit reflog records where HEAD and branches have been, so you can recover lost commits. Reference for show, ex…
git checkout: Usage, Options & Common CI Errorsgit checkout switches branches and restores files. Reference for -b, --detach, and pathspecs, plus the detach…
git revert: Usage, Options & Common CI Errorsgit revert undoes a commit by creating a new inverse commit, keeping history intact. Reference for -m, --no-c…