Is it possible with Git to perform a diff between two stashes?

For instance, I have the following stashes:

stash@{2}: On peformanceFix#3: 20170728T164841
stash@{3}: On peformanceFix#2: 20170727T073349

I want a diff between the two.

  • 1
    Should be able to simply do git diff stash@{2} stash@{3}
    – Confuzing
    Sep 15 '17 at 21:05
  • Also got the answer with one google search. It is the top search result for git diff two stashes stackoverflow.com/questions/7677736/git-diff-against-a-stash
    – Confuzing
    Sep 15 '17 at 21:42
  • 2
    The command from the first comment works, and in fact gives me the same output as the one in the accepted solution. However, the thread linked in the second comment is about a different question, and contains neither of these solutions. Dec 12 '18 at 15:22

As mentioned by Confuzing and Per Quested Aronsson in the comments, the simplest solution is:

git diff stash@{2} stash@{3}

It also works with the -p added, but that does not add much value.

git diff -p stash@{2} -p stash@{3}

Oddly, Git's documentation does not suggest to use twice the -p option. I just tried it and found out it worked.

  • 2
    Seems to work without the -p option as well, at least in git version 2.16.2 Jan 23 '20 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.