32

Can I list the names of the modified files in a stash, without their contents?

While searching, I only found people printing the whole diff, couldn't manage to view the filenames only.

SQB
  • 3,926
  • 2
  • 28
  • 49
o0'.
  • 11,739
  • 19
  • 60
  • 87

1 Answers1

51

The show sub-command, in the end, invokes git diff with whatever flags you have set, or --stat if you did not set any, so simply git stash show --name-only, which runs git diff --name-only between the base commit and the work-tree commit.

(See here and here for a description of what I have taken to calling a "git stash-bag". You get a diff between the commit the bag hangs from, and the w commit.)

Community
  • 1
  • 1
torek
  • 448,244
  • 59
  • 642
  • 775
  • If you're having the opposite problem, e.g. YADR shows the names only when you run `git stash show`, try `git stash show --patch`. – Carl G Jun 21 '19 at 11:25
  • git stash show --name-only stash@{0} for a selected stash – Rachita Nanda Sep 29 '22 at 09:18
  • 1
    @RachitaNanda: yes, or in modern Git you can just write the number (`git stash show 2` for stash stack entry #2 for instance). Note that I recommend avoiding `git stash` as much as possible; if you have a stack of five stashes, you have five stashes too many. :-) – torek Sep 29 '22 at 13:53