Git bisect plan to find the commit that introduced a bug
Plans a git bisect session to pin down the exact commit that broke something, with a good and bad starting point, a fast repeatable test, a script for automatic bisect and what to do with merge commits and builds that fail for other reasons. Use it when something worked last month, fails now, and the history between is long.
The output this prompt produced, unedited.
The prompt
What to give
Repository and language: [e.g. a Node.js API with a test suite]
What broke and how you notice it: [e.g. invoice totals off by one rupee on orders with coupons]
A commit or tag known to be good: [paste, or a date it last worked]
A commit known to be bad: [usually the current main]
How to build and run the check: [paste commands]
Anything that makes old commits hard to build: [e.g. a dependency that moved, a database migration]
Checklist before starting
The bad behaviour can be reproduced in under two minutes.
The check gives the same answer every time on the same commit.
The good commit really passes the check today.
Local changes are stashed and the working tree is clean.
Output format
The commands to start, mark good and bad, and finish the bisect.
A small test script that exits 0 for good, 1 for bad and 125 to skip a commit that will not build.
The command to run bisect automatically with that script.
What to do when the result is a merge commit or a skipped range.
A template to record the result: commit, author date, change summary and the likely line.
Guardrails
Never rewrite history or force-push during the hunt.
The test checks the one symptom only, so unrelated failures do not mislead the search.
git bisectfind breaking commitregression huntinggit debuggingautomated bisect scriptversion control
How to run this
Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.
The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.