I think git bisect
with a --no-parent
flag could do this easily, but it doesn't exist.
The only thing I can think of involves recreating just the branch commits in a new branch. Here's an example in the Linux shell:
$ git branch bisecttemp <first>
$ for h in `git log --oneline --decorate --first-parent --reverse --format=%H <first>..<last>`; do git checkout -f $h; sleep .5; git reset bisecttemp; git commit -am"$h"; git checkout testing; git reset --hard HEAD@{1}; done
That makes a bisecttemp branch off the <first>
commit we care about, gets a list of just the hashes between the <first>
and <last>
commits in the range we care about, visits each, resets back to the bisecttemp branch after each, without changing the working tree, commits everything different with the hash of the commit it came from, checks out bisecttemp again, and then resets it back to the last place head was, which is the new commit.
There may be a smarter way to do all of this, but the basics are that it creates a new branch off the start of the range of commits we care about, then commits the state of the branch-only commits (regular commits and merges, but not any sub-branch commits) to it, in order. You can't just cherry-pick here, as cherry-picks look at parents, and that would fail on the merge commits.
This isn't really tested, and could all be wrong. It's just a thought. It could all be rolled up in a function that takes a range of commits.