Imagine customers can sign in, but payment has stopped working after the latest release. Several changes have landed since the version that worked. Some came from developers, others from AI coding agents. Where do you start?
Asking for another patch is easy. Knowing what that patch needs to correct takes investigation. Git keeps the recorded checkpoints; git bisect helps your team find where the behavior changed.
If agents help your team produce more changes, that history can become harder to inspect one change at a time. Bisect gives you a way to ask a narrower question before more code is added: which checkpoint first fails the payment check?
First, make the payment failure repeatable
“Checkout is broken” is a complaint, not yet a useful test. Make the expected action specific: a customer signs in, pays 900, and receives a receipt showing that amount as paid.
Record the failing release’s commit, the test inputs, and the configuration. Then check the same action on a version believed to work. If the earlier version also fails, the starting boundary needs investigation. If the same version alternates between passing and failing, settle that instability before searching history.
For the small checkout example here, the test calls the sign-in function and uses the returned session to request a paid receipt. At the latest checkpoint, that call fails:
$ git log -1 --oneline
7158e24 G: prepare release notes
$ python ../check_payment.py .
FAIL: signed-in customer cannot complete payment
ValueError: Payment requires an authenticated session
Exit code: 1This check isolates a code behavior. Your product may also need a browser, database, or service to reproduce its failure. Those dependencies must stay controlled across the versions being tested. A payment provider outage will not necessarily have a responsible code commit in this history.
Are these just the commits you could revert?
A commit records a code checkpoint, and its hash identifies it. You may already know that your developer can revert a change or cherry-pick a particular fix onto another branch.
But which change should they choose? A login update, payment refactor, and several unrelated changes may all have landed since the last working release. The latest author is not automatically responsible.

Bisect helps find the boundary. A revert or a new fix comes after your team understands what that boundary means.
How does Git avoid checking every version?
Picture seven checkpoints, A through G. Payment works at A and fails at G. Git selects an intermediate revision, and your developer runs the same check there.
In this history, D fails. C fails. B works. Those answers identify C as the first failing checkpoint. Letters make the path easier to follow; Git operates on their commit hashes.
Find where the behavior changed
Seven checkpoints. The same sign-in and payment check classifies the versions Git selects.
Payment works at A and fails at G with the same check. The first failing change is somewhere between them.
Read the full explanation
- Establish the boundary. Payment works at A and fails at G with the same check. The first failing change is somewhere between them.
- Test D: it fails. The payment failure already exists at D. The boundary is now between the working A and failing D.
- Test C: it fails. C also fails the same payment check. Git narrows the interval to the working A and failing C.
- Test B: it works. B passes, leaving C as the first failing commit in this history. Inspect C’s patch and confirm the session lookup mismatch before repairing it.
Git selects revisions using the project’s ancestry, so a branched history need not follow this neat alphabetical pattern. The principle remains: Git chooses a version; your test supplies the answer. It does not understand payment behavior by reading the commit message.
What does your team actually run?
Use a clean investigation checkout with isolated test resources. Preserve unfinished work first. A separate worktree, as explained in part 2, can keep the investigation away from an active task.
From that checkout, the setup is:
git status --short --branch
git bisect start
git bisect bad BAD_COMMIT
git bisect good GOOD_COMMIT
Replace BAD_COMMIT with the inspected failing revision and GOOD_COMMIT with a known working ancestor. The example’s endpoints are G and A. Git now checks out a revision to test.
Run the focused payment check. In the downloadable example, the check lives beside the repository so it remains available while old versions are checked out:
python ../check_payment.py .
Then choose one classification:
| What happened at this revision? | What your developer runs | What the answer means |
|---|---|---|
| The payment check passes | git bisect good | This revision works for the check |
| The payment assertion fails | git bisect bad | This revision has the behavior being investigated |
| The revision cannot be tested reliably | git bisect skip | No reliable classification is available |
Repeat the check and classification on the revision Git selects next. Do not run all three classifications as a recipe. A dependency that cannot install is a different observation from a customer payment failing.
$ git log -1 --oneline
7db84ee D: add checkout notes
$ python ../check_payment.py .
FAIL: signed-in customer cannot complete payment
ValueError: Payment requires an authenticated session
$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 1 step)
[a39f99047e764c7d2c78623059bf286e48ef0c06] C: change payment session lookup
$ git log -1 --oneline
a39f990 C: change payment session lookup
$ python ../check_payment.py .
FAIL: signed-in customer cannot complete payment
ValueError: Payment requires an authenticated session
$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[c88b3a0829ed695b3885356308a6d7132f7008f5] B: document receipt fieldsCan the test do the answering automatically?
Once the check is reliable, it can supply the classifications:
git bisect run python ../check_payment.py .
Our example harness returns 0 when the receipt is correct, 1 when the payment behavior fails, and 125 when it cannot classify the revision. Git treats 1–127 except 125 as bad; other exit codes abort. The official bisect manual documents that contract.
This is why the harness needs its own error handling. A missing executable can otherwise look like a bad revision. Confirm the command works on the known good and bad endpoints before letting it classify the search.
$ git bisect run python ../check_payment.py .
running python [demo]\check_payment.py [demo]\app
FAIL: signed-in customer cannot complete payment
ValueError: Payment requires an authenticated session
Bisecting: 0 revisions left to test after this (roughly 1 step)
[a39f99047e764c7d2c78623059bf286e48ef0c06] C: change payment session lookup
running python [demo]\check_payment.py [demo]\app
FAIL: signed-in customer cannot complete payment
ValueError: Payment requires an authenticated session
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[c88b3a0829ed695b3885356308a6d7132f7008f5] B: document receipt fields
running python [demo]\check_payment.py [demo]\app
PASS: signed-in customer receives paid receipt for 900
a39f99047e764c7d2c78623059bf286e48ef0c06 is the first bad commit
commit a39f99047e764c7d2c78623059bf286e48ef0c06
Author: Cimulink Demo <demo@example.invalid>
Date: Thu Oct 1 12:02:00 2026 +0000
C: change payment session lookup
checkout.py | 2 +-
notes.md | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
bisect run successRun the same checkout example
Download the checkout investigation files, extract them, and open a terminal in the extracted folder. You need Git and Python; the test uses Python’s standard library.
git clone history.bundle app-investigate
cd app-investigate
git bisect start demo-bad demo-good
git bisect run python ../check_payment.py .
git bisect reset
The bundle provides the seven recorded checkpoints. The checker is outside the changing checkout. The example exercises sign-in and receipt functions; adapt the test to the behavior and environment your team actually needs to investigate.
The first failing commit is found. Is anything fixed?
Not yet. Keep the search record, inspect the identified commit, and exit the session:
git bisect log
git show FIRST_BAD_COMMIT
git bisect reset
Save the log output if the investigation needs a handoff. Substitute the reported hash for FIRST_BAD_COMMIT. The reset returns to the original checkout position; it does not deploy a repair.
In C, the payment function starts looking for active in a session that sign-in still returns as authenticated. Inspecting that mismatch connects the failing check to a specific code decision. Confirm it against the neighboring working revision before choosing a repair.
A revert creates a new change reversing an earlier patch. A forward fix changes the current code to restore the intended behavior. Your developer needs to consider later dependencies before deciding between them. In this checkout example, restoring the agreed session lookup makes the check pass again.
The search ends. The repair still needs checking.
- Find the boundaryInspect C’s patch
- Prepare the repairReview dependencies
- Check the fixSign in and pay
- Release and verifyCheck the running flow
The repaired version still needs review, relevant tests, and release verification. Git does not undo database changes or correct customer records just because a code change was reversed.
What should you ask before another patch is written?
Bisect helps when many changes separate working and failing versions, the cause is unclear, or an agent begins guessing at repairs. It needs reliable classifications. Skipped revisions may leave several possible commits; a bug that disappears and returns can also undermine the search.
Ask your team:
“Which version last passed this payment check, where does it first fail, and what evidence supports the repair?”
That gives the next patch a specific behavior to restore. Part 5 connects task scope, checks, and recovery into the day-to-day workflow.