Difference between single commit on branch and trunk

217 views Asked by At

I have seen all the questions about diffing files but none that really matches my usecase.

The situation:

a - b - c - d (master)
 \ e (tag) - f - g - h (my_branch)

Now i would like to see a diff just like if i had cherry-picked h onto d.

This happens when you are working on a stable version of a software and need to send a patch against trunk.

Anyone know how i can produce such a diff?

2

There are 2 answers

3
David Deutsch On BEST ANSWER

To see the difference between the 2 commits, simply do git diff h d.

Editing in response to comments

The fewest steps I can think of is:

git checkout master
git cherry-pick h --no-commit
git diff --staged
git reset --hard
0
bruceyyy On

The best i can come up with is that you do the cherry pick without committing and then you can see the diff, not very elegant i know

git cherry-pick -n <commit>    # get your patch but dont commit

and then you can use git diff to view the changes and then if you dont actually want to commit them but instead get rid of them

git reset    # unstage
git checkout -- application/  # or whatever folder your files are in

So thats my best attempt, hope it helps somewhat