views:

61

answers:

3

I have two branches, and I am merging branch1 into branch2 with a no fast-forward.

After the merge, I run the command 'git show', I only get the message that of the commit (which is the merge from the no fast-forward) and no list files that changed.

How do I get the list files changed in the merge?

SOLVED:

When at branch2 after the merge, I used the following:

git diff HEAD~

That returned the correct result.

+1  A: 

Did you try with the git whatchanged command? (not tested):

git whatchanged --oneline

or

git whatchanged --oneline ..HEAD^
git whatchanged --oneline ..HEAD^2

--oneline

This is a shorthand for "--pretty=oneline --abbrev-commit" used together.

What I need is to see all the files that changed in branch1 that were merged to branch2.

branch2 may be represented here by HEAD^2, the second parent of HEAD.

As for "just the list of files":

git diff --name-status ..HEAD^2

should give you only a list of file with their associated status.

VonC
That gives me all changes for all commits, same as 'git log'. What I need is to see all the files that changed in branch1 that were merged to branch2.
chafnan
@chafnan: did you try '`--oneline`' with `HEAD^2` (which should represent `branch2`). See my updated answer.
VonC
A: 

After doing the merge, check the output of git reflog, which tracks where the tips of branches have been. The first line should be your merge commit, and the second should be where branch2 was before the merge. If that looks right, you can see from the second column of that output that the previous commit can be referred to as HEAD@{1}, so to see which files were changed by the merge, you could do:

git diff --stat HEAD@{1}
Mark Longair
That gets me closer, but branch1 had multiple commits. How do I get the diff on all commits?
chafnan
So you'd like to see all files changed in both `branch1` and `branch2` from when they diverged to when they merged? If so, and assuming your branch is still at the merge commit, I think you could do that with `git diff --stat $(git merge-base HEAD^1 HEAD^2)`
Mark Longair
A: 

When at branch2 after the merge, I used the following:

git diff HEAD~

That returned the correct result.

chafnan