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.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github