How do I get the interdiff between these two git commits?
Perhaps something like this:
git log -p -1 new_commits > patch.new
git log -p -1 old_commits > patch.old
diff patch.old patch.new
Or for a terse one-liner (in bash
):
diff <(git log -p -1 old_commits) <(git log -p -1 new_commits)
Git 2.19 introduces a new command, git range-diff
which does this:
git-range-diff - Compare two commit ranges (e.g. two versions of a branch)
git range-diff [--color=[<when>]] [--no-color] [<diff-options>] [--no-dual-color] [--creation-factor=<factor>]\ ( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> )
Description
This command shows the differences between two versions of a patch series, or more generally, two commit ranges (ignoring merge commits).
To that end, it first finds pairs of commits from both commit ranges that correspond with each other. Two commits are said to correspond when the diff between their patches (i.e. the author information, the commit message and the commit diff) is reasonably small compared to the patches' size. See
Algorithm
below for details.Finally, the list of matching commits is shown in the order of the second commit range, with unmatched commits being inserted just after all of their ancestors have been shown.
So, in your case:
git range-diff base old_commits new_commits
Would automatically match up the commits made in the old_commits
branch with the commits in the new_commits
branch, and display a summary of the differences between each commit.
Or, if you just want the changes from the last commit in each of those branches, you'd run:
git range-diff old_commits~..old_commits new_commits~..new_commits
For more on range-diff, see the official documentation.