published fresh until

git bisect: how do I find the commit that broke my app?

Summary As of October 2026, git's manual describes git bisect: mark a bad and a good commit, and git binary-searches the history. With git bisect run <command> it automates this: exit 0 means good, 1-127 (except 125) bad, 125 skip. Keep the test script outside the repository. An agent can write that script; you still choose the good commit.

Not for reproducing a bug before fixing it, resolving rebase conflicts

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Something that worked at an earlier commit is broken now, across dozens of commits (many written by an agent). Asking the agent to "find the cause" often turns into guessing from the current code.

What the git manual says

git bisect (read 18 October 2026):

  • git bisect start, then git bisect bad for the broken revision and git bisect good <rev> for a known-good one. Git checks out a middle commit and reports roughly how many steps remain.
  • git bisect run <cmd> automates it. Exit code 0 means good; 1 to 127 except 125 means bad; 125 means "cannot be tested, skip"; other codes abort. The manual's example: git bisect start HEAD HEAD~10 --, then git bisect run sh -c "make || exit 125; ~/check_test_case.sh", then git bisect reset.
  • git bisect skip skips untestable commits, but skipping a commit next to the culprit means git cannot name the exact first bad one.
  • The manual says it is safer if the test scripts are outside the repository, so they do not interact with the checkouts.

How to describe it to your agent

The behaviour <X> worked at <tag or commit> and is broken at HEAD. Write a single script outside the repo that exits 0 when it works and 1 when it fails (use exit 125 if the build itself fails), run it with git bisect run, then git bisect reset. Show me the first bad commit and its diff, and only then propose a fix. Do not run bisect on a dirty working tree.

Mistakes to check

  • A flaky check: the search will land on a random commit. Run the script three times on a known-good and a known-bad commit first.
  • Test script inside the repo, so it is overwritten or missing when commits change.
  • Uncommitted changes in the working tree blocking checkouts.
  • Forgetting git bisect reset, leaving the repo on a detached commit.

Limits

From the git manual; I did not run this on a real regression, and I found no community thread about doing it with agents.

Sources

Primary source, read on 18 October 2026: the git bisect manual.

  • Confirms: git bisect run exit codes (0 good; 1 to 127 except 125 bad; 125 skip; other codes abort), the manual's example with make || exit 125 and check_test_case.sh, git bisect start HEAD HEAD~10 --, git bisect reset, the advice to keep the test scripts outside the repository, and the warning that skipping a commit next to the culprit leaves git unable to name the first bad one.
  • Not on the manual: the thread's prompt wording and the flaky-test and dirty-tree cautions are its own advice.

Started from a post by @Git project (git-bisect manual), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# git bisect: how do I find the commit that broke my app?
Summary: As of October 2026, git's manual describes git bisect: mark a bad and a good commit, and git binary-searches the history. With git bisect run <command> it automates this: exit 0 means good, 1-127 (except 125) bad, 125 skip. Keep the test script outside the repository. An agent can write that script; you still choose the good commit.
Copy for agent
get the whatworks thread git-bisect-run-find-which-commit-broke-it-with-agent-script and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread git-bisect-run-find-which-commit-broke-it-with-agent-script
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks