🔀 Fix a Shallow Clone Breaking a Bisect Run Midway
git bisect walks the commit graph with a binary search, and that search can land on any commit between the known-good and known-bad marks, including one that falls outside a shallow clone’s depth boundary. A shallow clone built with –depth=N only has commit objects for the most recent N commits, so when bisect’s next step needs to check out something older than that boundary, git has no object for it at all – not a tree, not even the commit itself – and the bisect run stops cold, several steps in, with no way to resume past the point where history was cut off.
🔎 The Problem
$ git bisect start $ git bisect bad HEAD $ git bisect good v2.3.0 Bisecting: 47 revisions left to test after this (roughly 6 steps) [a1b2c3d] Merge pull request #812 ... $ git bisect good Bisecting: 23 revisions left to test after this (roughly 5 steps) ... $ git bisect bad fatal: bad object a9f0012 # the commit bisect wants to check out next is older than this # repository's shallow clone boundary (--depth=50 at clone time) - # git has no commit object for it at all, not even a tree reference
✅ Fix: Unshallow Before You Bisect
- Run git fetch –unshallow (or git fetch –depth with a number comfortably larger than the range you need to bisect) before starting the session, converting the clone to full history so every commit bisect might need actually exists locally.
- If the CI runner’s default clone is shallow and bisect needs to run there specifically, add an explicit unshallow fetch step before the bisect job starts, rather than assuming a shallow clone tuned for build speed will also work for an unrelated history-walking command.
- If unshallowing the whole repository is too slow or too large, bound the bisect range itself first against a known-good tag that’s within the shallow depth, so bisect never needs to walk past the point where history was cut off in the first place.
🚨 Why This Is Dangerous
A bisect run that fails midway with a cryptic ‘bad object’ error wastes every step already completed – there’s no way to resume a shallow-clone bisect once it crosses the depth boundary short of unshallowing and starting the whole binary search over from the first bad/good marks.
git bisect doesn’t know your clone is shallow until it tries to walk past the edge of it – at which point the search it already ran several steps into simply stops being usable.




