I have a feature branch feature/foo
and a development branch develop
I want to merge the feature to.
I already did a code review at a later point. Now further changes have been pushed to feature/foo
. Those consist of merges with the development branch.
How can I identify the differences of the potential merge commit to develop
to the previous – already reviewed – state which has not actually be merged?
In other words, what are the changes between review 2 and review 1 which are relevant for the merge?
I encounter this regularly when reviewing code as part of pull requests (GitHub) or merge requests (GitLab) using the web interface. The solution may be outside such web interfaces as it shall only support the analysis.
Simply comparing changesets is not what I am looking for.
Because that would also generate differences for (irrelevant) changes which would not be touched by a merge.
Assuming the first review took place between the commits 0xf001
(feature/foo
) and 0xDEF1
(develop
). And the second review shall be between the commits 0xf002
(feature/foo
) and 0xDEF2
(develop
).
First identify the changes which have been introduced by the feature branch (note the three dots):
git diff --patch --cc 0xDEF1...0xf001 > patch1.diff
git diff --patch --cc 0xDEF2...0xf002 > patch2.diff
Now compare the differences:
diff -u patch1.diff patch2.diff