Unfortunately, without creating new commits somehow, this isn't really defined. It's possible that the diff introduced by J
doesn't even make sense without what was merged in I
, namely B
and C
.
Assuming that J
really is disjoint from B
and C
, you do need to create new commits somehow in order to get the combined diff, because what you're asking for is impossible (in general) to determine without iteratively applying patches and seeing what the result is. The quickest way to do this, though, is not by cherry-picking. Instead you can take advantage of the fact that rebase
by default does not preserve merge commits. Therefore:
# create a temporary copy of branch A
git branch branch-A-tmp branch-A
# rebase that copy in place, thus removing the merge commits
git rebase commit-A branch-A-tmp
# examine the diff
git diff commit-A branch-A-tmp
If the changes made in J
are not separable from those in B
and C
, merged in I
, you'll get merge conflicts when rebase attempts to re-apply J
, thus indicating that the diff you're asking for is not well-defined. Otherwise, you'll get the diff you're looking for.