🔀 Git: Fix git bisect Jumping Straight to a Verdict Without Testing Any Intermediate Commit Because the Range Only Contained Two Commits
git bisect works by binary-searching the commit range you give it, checking out the midpoint and asking you to mark it good or bad — but when the range you started with contains only two commits, with nothing in between, there is no midpoint left to test at all, so bisect has nothing left to do except declare the known-bad commit the answer immediately, without you ever running a single test. This looks exactly like bisect skipping your testing step, when really it already ran out of commits to bisect the moment you gave it the range.
🔎 The Problem
$ git bisect start $ git bisect bad HEAD $ git bisect good HEAD~1 Bisecting: 0 revisions left to test after this (roughly 0 steps) [abc1234] <commit message of HEAD> # No test ever ran - HEAD~1 to HEAD is only one commit apart, # so the "bad" commit IS the midpoint, and bisect is already done
âś… Fix: Give Bisect an Actual Range to Search
- Start the bisect range further back from a commit you’re genuinely confident was still good, rather than the commit immediately before the one you suspect — a one-commit gap gives bisect nothing left to actually test.
- If you only have a narrow suspect range, just test that single commit directly instead of invoking bisect at all, since binary search provides no benefit once the search space is down to one candidate.
- When bisect does have a real range to search, use git bisect run with an automated test script instead of manually marking each step, so you don’t accidentally shrink the range yourself by guessing a narrower starting point than you actually need.
🚨 Why This Is Dangerous
- Mistaking “bisect gave an instant answer” for “bisect found the actual root cause through testing” can leave you confidently blaming the wrong commit, especially if your good/bad boundaries were already a guess rather than something you’d actually verified before starting.
Bisect can only test what’s between your two boundaries — give it a one-commit gap and it isn’t skipping the search, it’s telling you there was never a search left to run.
