8

My repository history looks something like this:

 x---y-+-z-+-branch / / / ---a---b---c-+-d-+-e---master 

I want to get a single diff (i.e., like 'git diff' outputs- I don't want a whole bunch of diffs like 'git log -p' produces) of the complete history of 'branch', without including any of the changes that were merged into 'branch' from 'master'.

How can I do this?

1
  • not a real answer but maybe a direction: I don't think it is possible only with git tools. You could do some crazy shell hacking to do this. A good starting point: Show all commit shas which are only in your branch: git log branch_name --not master --no-merges --pretty="format:%H" Commented Mar 12, 2013 at 22:45

1 Answer 1

7

The command you are looking for is:

git diff master...branch 

From git help diff:

git diff [--options] <commit>...<commit> 

This form is to view the changes on the branch containing and up to the second

Sign up to request clarification or add additional context in comments.

7 Comments

"...starting at a common ancestor of both <commit>" - does that mean it's only going to provide me a diff of the changes since the last time I merged 'master' into 'branch', and not the entire history of 'branch'?
have you tried the command? it will diff d against branch in your drawing. That will show all the changes that only happened on branch, since you created it (b).
Indeed, this command does show what I need. I'm not clear why, though, given the above snippet from the command's help section.
What exactly is confusing you? Or describe what you think this command does / should do (based on your understanding).
As the docs say the command shows a diff from the common ancestor, given the above graph, I expected the diff to only show changes since the last time I merged master into branch, since all commits on master prior to that would be common to branch. Here, that would be an empty diff. Typing this out (yay rubber duck programming!), I now realize the command works because although master's commits are now on branch, branch's commits aren't on master. If I first merged branch into `master', then vise versa, that should be the new common ancestor from which the diff starts, yes?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.