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: 1
The tested revision and failing action give the investigation a concrete starting point.

This 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.

A magnifying lens focuses on one checkpoint in a long line, representing an investigation narrowing from project history to a specific change.
Start with the history, then narrow the change worth inspecting.

Bisect helps find the boundary. A revert or a new fix comes after your team understands what that boundary means.

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.

Cimulink / A closer lookFollow the changes

Find where the behavior changed

Seven checkpoints. The same sign-in and payment check classifies the versions Git selects.

Known workingKnown failing
Aworks
Buntested
Cuntested
Duntested
Euntested
Funtested
Gfails
A → G
PAY
Same session · same amountCan the signed-in customer receive a paid receipt?
Git chooses a revision. Your check supplies the answer.
1 / 4
Establish the boundary

Payment works at A and fails at G with the same check. The first failing change is somewhere between them.

Bisect narrows history using your answers. An untestable revision needs skip; flaky results or a defect that disappears and returns can undermine the search.
Read the full explanation
  1. Establish the boundary. Payment works at A and fails at G with the same check. The first failing change is somewhere between them.
  2. Test D: it fails. The payment failure already exists at D. The boundary is now between the working A and failing D.
  3. Test C: it fails. C also fails the same payment check. Git narrows the interval to the working A and failing C.
  4. 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 runsWhat the answer means
The payment check passesgit bisect goodThis revision works for the check
The payment assertion failsgit bisect badThis revision has the behavior being investigated
The revision cannot be tested reliablygit bisect skipNo 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 fields
Each answer refers to the revision just tested. Here D and C fail; Git selects B to narrow the boundary further.

Can 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 success
The automated search reaches C. Inspect the change before deciding how to repair it.
Run 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.

Cimulink / From finding to repair

The search ends. The repair still needs checking.

  1. Find the boundaryInspect C’s patch
  2. Prepare the repairReview dependencies
  3. Check the fixSign in and pay
  4. Release and verifyCheck the running flow
A first-bad commit is a starting point for a repair decision, not a deployment.

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.