Search code examples
gitgit-diff

Difference between single commit on branch and trunk


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?


Solution

  • 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