Tell it good and bad. It tells you the guilty commit.
Binary-search through commit history to find the commit that introduced a bug. You mark a known-good and a known-bad commit; Git checks out the midpoint and asks you to test it. Repeat until it tells you the guilty commit.
Bisect maintains a search range in the DAG. Each step halves it: if the midpoint tests good, the bug is in the newer half; if bad, the older half. Logarithmic — finds the bug in log2(N) steps.
git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]
[--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]
git bisect (good|bad) [<rev>...]
git bisect skip [(<rev>|<range>)...]
git bisect reset [<commit>]
git bisect (visualize|view)
git bisect replay <logfile>
git bisect log
git bisect run <cmd>...
git bisect help| Flag | What it does |
|---|---|
start | Begin a bisect session. |
good <rev> | Mark <rev> as known-good. |
bad <rev> | Mark <rev> as known-bad. |
skip | Skip the current commit (untestable). |
reset | End the session, restore HEAD. |
run <cmd> | Automate: Git runs <cmd> at each step. Exit 0 = good, non-zero = bad. |
$ git bisect start HEAD v1.0<rev>) as known-good.$ git bisect good<rev>) as known-bad.$ git bisect bad$ git bisect skip$ git bisect run make test$ git bisect reset$ git bisect log$ git bisect replay /tmp/bisect.log$ git bisect start
$ git bisect bad # current is bad
$ git bisect good v1.0 # v1.0 was good
# ... test, mark good/bad each step ...
$ git bisect reset$ git bisect start HEAD v1.0
$ git bisect run make testgit bisect run whenever you can write a deterministic test that returns non-zero on failure.git bisect skip rather than guessing.git bisect reset leaves you on a strange detached HEAD.skip it.Hit each option, then Check answers. Score is recorded; Next is always open.