Git in a Minute · intermediate

Git in a Minute: Bisect

git bisect binary-searches history to find which commit introduced a bug—vital when agent commits are frequent.

Last verified: 2026-09-06

In one sentence

git bisect walks commit history in binary-search order to find the first bad commit between a known good and known bad state.

Why it matters

Agent sessions can land many commits quickly. When something breaks later, guessing wastes time. Bisect makes history searchable.

How it works

git bisect start
git bisect bad HEAD
git bisect good <known-good-sha>
# test each checked-out commit, then:
git bisect good   # or: git bisect bad
git bisect reset

Automate with git bisect run ./script-that-exits-nonzero-on-fail when you have a deterministic check.

Example

After a week of agent PRs, a flaky auth bug appears. Mark last release as good, tip as bad, and bisect with a focused failing test.

Agentic coding use

Bisect rewards clean commits and green CI. If agents squash unrelated changes together, bisect still runs—but the “bad commit” becomes a pile instead of a cause.

Watch out

Bisect assumes the bug is a regression between two points and that your test is trustworthy. Non-deterministic failures will mislead the search.

Sources