gitdiffgit-stashgit-show

View diff contents of 1 specific stashed file in Git


Let's say I have 2 stashed files:

$ git stash show

a.txt | 2 +-
b.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

I can view the complete diff of the stash:

diff --git a/a.txt b/a.txt
index bc56c4d..a688182 100644
--- a/a.txt
+++ b/a.txt
@@ -1 +1 @@
-Foo
+Baz
diff --git a/b.txt b/b.txt
index ebd7525..4105321 100644
--- a/b.txt
+++ b/b.txt
@@ -1 +1 @@
-Bar
+Qux

More files would clutter the output, so I want to view only 1 specific file. However, the manual appears to say there isn't an option for using a filename argument:

NAME
       git-stash - Stash the changes in a dirty working directory away

SYNOPSIS
       ...
       git stash show [<stash>]
       ...

Is there a way to view the diff contents of only 1 specific stashed file?


Solution

  • Building on How would I extract a single file (or changes to a file) from a git stash? you could:

    git diff stash@{0}^! -- a.txt