Skip to content
The Git Crypt

/static/cripta/en/ossada/bisect/

Menu

GIT-005 · Archaeology

git bisect

Binary search for the guilty commit — history interrogated by halves.

You know today is broken and that some old version worked. git bisect cuts that interval in half, checks out the middle commit and asks: good or bad? Each answer discards half the suspects — a thousand commits fall in ten questions.

The master stroke is git bisect run: hand it a command that exits 0 on success — the test suite, a script — and the whole dig runs by itself, until the first bad commit is left standing, named in the final report.

$ git bisect start
$ git bisect bad
$ git bisect good v1.4.0
Bisecting: 44 revisions left to test after this (roughly 6 steps)
$ git bisect run go test ./...
2f9d1c3f8a4b6e0d7c5a9e2b1d8f4a6c3e7b0d95 is the first bad commit
Six questions later, the culprit has a name.