See What’s in a Stash without Applying It?

Better Stack Team
Updated on June 24, 2024

To see what's in a stash without applying it, you can use the git stash show command. This command displays the changes that are currently stashed. By default, it shows a summary of the changes made to files in the stash.

Here's how you can use it:

 
git stash show

This command will display a summary of changes made to files in the most recent stash. If you have multiple stashes, you can specify which stash to show by providing its index:

 
git stash show stash@{<index>}

Replace <index> with the index of the stash you want to show, starting from 0 for the most recent stash.

Viewing Detailed Changes:

If you want to see detailed changes, including the contents of added or modified files, you can use the -p or --patch option:

 
git stash show -p

This command will display a unified diff of the changes made to files in the stash.

Note:

  • The git stash show command only shows information about changes in the stash; it does not apply or remove the stash from the stack.
  • Viewing the stash with git stash show allows you to review the changes before deciding whether to apply or drop the stash.
  • If you want to apply the stash, you can use git stash apply. If you want to remove the stash from the stack without applying it, you can use git stash drop.
Got an article suggestion? Let us know
Explore more
Git
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.