git bisect Find the commit that introduced a bug
Does a binary search through history. You say which commit is bad and which was good, and Git checks out the middle one for you to test, halving the range each time.
Synopsis
git bisect start [BAD [GOOD]]
git bisect good | bad | skip
git bisect run COMMAND
git bisect reset
Common options
| Option or form | What it does |
|---|---|
start | Begin a bisect session |
bad [COMMIT] | Mark a commit (default: current) as having the bug |
good [COMMIT] | Mark a commit as working |
run COMMAND | Test automatically: exit 0 means good, 1 to 127 (except 125, which means skip) means bad |
skip | Skip a commit that cannot be tested |
reset | End the session and return to where you started |
Examples
git bisect start
git bisect bad
git bisect good v1.2.0
Bisecting: 14 revisions left to test after this (roughly 4 steps)
git bisect good
git bisect run npm test
git bisect reset
Notes
- Always finish with git bisect reset, or you stay on a detached HEAD in the middle of history.
- A history of 1000 commits needs only about 10 checks.
- Commit or stash your work first, because bisect checks out other versions.
See also
Last reviewed 2026-10-09.