Reputation: 596
Following a git fetch, I'd like to review code changes that are introduced from upstream.
I can use git log -p ..@{u}
, however the output will not include diffs of merge commits/merges of pull requests.
Is there a way to include those in the output, that will yield a comprehensive history of changes that occurred since I last pulled?
Thanks
Upvotes: 0
Views: 172
Reputation: 488193
When using git log -p
to view commits as patches, it does—as you noticed—skip merge commits when it comes time to diff them. That is, it shows you the log message as usual, but no diff at all.
You have three options for controlling this:
-c
(one hyphen and one lowercase C): show one form of combined diff--cc
(two hyphens and two lowercase Cs): show the other form of combined diff-m
: "split" each merge, showing a patch against each parent. In this case you will see the log message twice.The combined diff format is described in a separate section of the git diff
documentation (and several others that share this file). For some reason, though,1 a key fact is hidden in this earlier section:
Note that combined diff lists only files which were modified from all parents.
Quite often this is actually what you want: if the merge kept file README.txt
the same as the README.txt
in either parent commit, it's probably not interesting to show a diff against the other parent commit. If you are not expecting this, however, it can be quite a surprise. The only way to defeat it is to use -m
.
1This makes some sense for git diff-tree
, git diff-files
, and git diff --raw
as the section itself is describing the files that will be listed, and files that match at least one parent will not be listed. However, if you haven't memorized this little fact and are just searching the documentation for the immediate next two sections ("generating patches with -p
" and "combined diff format"), the key sentence will probably not even be in your window. I still remember being burned by this, however many years later it is now. :-)
Upvotes: 1