It shows all the changes made to the merged branch as a result of the merge. Show activity on this post. git show -c c0f501 will display a combined diff from commit c0f501 to both of its parents, as printed by git diff during a merge. This gives a better overview than git show -m .
No, merging does only affect one branch.
I'll start by showing how the default “chronological” order of git log can mislead you when the history contains merge commits. Then I'll show how you can visualize Git merge history using git log --graph , and how to see the “true” history of a single branch using --first-parent .
The diff can be done with git diff (followed by the filename or nothing if you want to see the diff of all modified files). But if you already did something like git add * , you have to undo with git restore --staged . first.
Look at the commit message:
commit 0e1329e551a5700614a2a34d8101e92fd9f2cad6 (HEAD, master)
Merge: fc17405 ee2de56
Author: Tilman Vogel <email@email>
Date: Tue Feb 22 00:27:17 2011 +0100
Merge branch 'testing' into master
notice the line:
Merge: fc17405 ee2de56
take those two commit ids and reverse them. so in order get the diff that you want, you would do:
git diff ee2de56...fc17405
to show just the names of the changed files:
git diff --name-only ee2de56..fc17405
and to extract them, you can add this to your gitconfig:
exportfiles = !sh -c 'git diff $0 --name-only | "while read files; do mkdir -p \"$1/$(dirname $files)\"; cp -vf $files $1/$(dirname $files); done"'
then use it by doing:
git exportfiles ee2de56..fc17405 /c/temp/myproject
A better solution (mentioned by @KrisNuttycombe):
git diff fc17405...ee2de56
for the merge commit:
commit 0e1329e551a5700614a2a34d8101e92fd9f2cad6 (HEAD, master)
Merge: fc17405 ee2de56
Author: Tilman Vogel <email@email>
Date: Tue Feb 22 00:27:17 2011 +0100
to show all of the changes on ee2de56
that are reachable from commits on fc17405
. Note the order of the commit hashes - it's the same as shown in the merge info: Merge: fc17405 ee2de56
Also note the 3 dots ...
instead of two!
For a list of changed files, you can use:
git diff fc17405...ee2de56 --name-only
You can create branch with HEAD set to one commit before merge. Then, you can do:
git merge --squash testing
This will merge, but not commit. Then:
git diff
If you are sitting at the merge commit then this shows the diffs:
git diff HEAD~1..HEAD
If you're not at the merge commit then just replace HEAD with the merge commit. This method seems like the simplest and most intuitive.
Seems like answered here: https://public-inbox.org/git/[email protected]/
So in a similar way, running
$ git diff --cc $M $M^1 $M^2 $(git merge-base $M^1 $M^2)
should show a combined patch that explains the state at $M relative to the states recorded in its parents and the merge base.
I think you just need 'git show -c $ref'. Trying this on the git repository on a8e4a59 shows a combined diff (plus/minus chars in one of 2 columns). As the git-show manual mentions, it pretty much delegates to 'git diff-tree' so those options look useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With