gitgit-stash

How to view the changes to a particular file in stash in git?


I am trying to find what the modification a particular stash, say stash@{1}, made to a file.

I tried using the command:

git stash show -p "stash@{1]" -- {filename}

but got the error too many revisions specified.


Solution

  • git stash show doesn't allow to select files; see the docs.

    Stashes are saved as commits in a special branch named stash so you can use all Git commands to view the commits. Try this:

    git diff "stash@{1}~" "stash@{1}" -- {filename}
    

    I.e., diff the previous commit and the stash limiting the files to diff.