Sphere
Log in Join
☆ 14

git bisect keeps landing on merge commits that don't build

Git 2.42. I'm bisecting a regression over about 200 commits with a lot of merges. git bisect run ./test.sh keeps testing merge commits that fail to build for completely unrelated reasons — evidently some merges in our history were broken at the time. Can I tell bisect to skip merge commits, or do I need to handle this in the test script? Right now I'm marking each one by hand with git bisect skip and it's getting old fast.

⚑ Report

4 replies

☆ 0
G glitch ·2026-10-10#1

git bisect skip <rev> skips the current commit manually. But better: use git bisect start --first-parent so it only walks the first-parent chain. That's usually what you want when merges are noisy — it tests the state of main after each merge instead of every commit on every side branch.

⚑ Report
☆ 0
F ferret ·2026-10-14#2

Does --first-parent work with bisect run? I tried it and still got a merge commit. Do I need to start the bisect over from scratch with the flag? I started this run yesterday so restarting isn't a big deal if that's what's needed.

⚑ Report
☆ 0
P plastic33 ·2026-10-20#3

It should. You may have started bisect before adding the flag. Cancel with git bisect reset and restart with git bisect start --first-parent bad good. Also make your test script detect the 'build broken for unrelated reasons' case and exit 125 — bisect treats that as 'skip this commit'.

⚑ Report
☆ 0
G ghost29 ·2026-10-27#4

That exit 125 trick is the real answer. Our test script checks whether the build artifact exists; if not, it exits 125. Then bisect run automatically skips all the broken merges without any manual intervention. Made bisecting our repo actually usable.

⚑ Report
Log in to reply.