Git diff after back and forth merging?

The basis of this question can be like at Finding a branch point with Git?

.-- X -- A -- B -- C -- D -- F  (master) 
.          \     /   \     /
.           \   /     \   /
.             G -- H -- I -- J  (branch A)

So I’m looking for a git diff which includes only commits of G+H+I+J

  • How to apply changes of a specific file of the other git repository to my own repo
  • How to see git diff from very beginning to the HEAD?
  • GIT diff GUI
  • Git diff between master and origin/master using Netbeans
  • How do diff/patch work and how safe are they?
  • Want to exclude file from “git diff”
  • I’m afraid it is not possible to get it because branchA was merged back to master several times, and master was also merged in to branchA several times.

  • Git compare before Merging 2 branches
  • How do I prevent git on Cygwin to set core.filemode=true
  • Can Git push / pull over the internet to distributed repos?
  • git filter-branch led to a disconnected history: how to get rid of the old commits?
  • Is there any personal information in the .git directory
  • git commit deleting all files in repo
  • 2 Solutions collect form web for “Git diff after back and forth merging?”

    git diff G J should give you G+H+I+J, but since you’re concerned about merging, what you want is probably the diff for G+H+J — excluding merges. I’m afraid you’d need to create a temporary branch and cherry-pick these commits to get the diff you need.

    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.

    Git Baby is a git and github fan, let's start git clone.