Search code examples
gitgit-diffgit-stashgit-stage

Diff a staged file with one in stash


Is there a --staged (aka --cached) option for comparing files from a git stash?

Here I'm comparing the most recent commit against a staged file (I'm using the explicit @{} syntax, but I know that @{0} can be inferred):

git diff stash@{0}:spec/blueprints.rb HEAD:spec/blueprints.rb

And here I'm comparing the stashed file with what's on disk:

git diff stash@{0}:spec/blueprints.rb spec/blueprints.rb

How can I compare what's currently staged with what's in the stash? This doesn't work:

git diff --staged stash@{0}:spec/blueprints.rb spec/blueprints.rb

Solution

  • git diff --cached 'stash@{0}' -- spec/blueprints.rb

    ... It is possible that quotes are not needed, but you never know how your shell can surprise you.