Is there a way to get meld
+ git
to display changes that happened between 2 git commits, but exclude changes introduced in a 3rd commit? The use case is to see how much current commit differs from some commit done before a 3-way merge.
I've got a hacky way to do that.
Warning: Before using single liner below, better commit/backup all your uncommitted changes. This single liner tries to stash and restore your changes. But it still may introduce some clutter (new files) at repo or may contain some bug
The code below shows a diff between FIRST_COMMIT
and SECOND_COMMIT
except changes to other files introduced by another branch in MERGE_COMMIT
. You should set env variables FIRST_COMMIT
, SECOND_COMMIT
and MERGE_COMMIT
to appropriate values.
FIRST_COMMIT=866dfa2a7
MERGE_COMMIT=94b195989
SECOND_COMMIT=0fc856fd9
git stash ; \
git checkout $FIRST_COMMIT ; \
git ls $MERGE_COMMIT..$SECOND_COMMIT | sort | \
uniq | \
xargs -L 1 git checkout $SECOND_COMMIT -- ; \
git difftool -d $FIRST_COMMIT ; \
git stash && git stash drop ; \
git stash apply
What this single-liner does:
stash
FIRST_COMMIT
MERGE_COMMIT
and SECOND_COMMIT
and all revisions between themSECOND_COMMIT
FIRST_COMMIT
and SECOND_COMMIT
except changes to other files introduced by another branch in MERGE_COMMIT
. The previous sentence means that if some file was modified both in SECOND_COMMIT
and in MERGE_COMMIT
, all changes will be present at diff. It's hard to avoid that.Depending on your prefered git workflow, you may decide to remove git stash calls from single liner above