Git

How to See What’s in a Stash Without Applying It

On Git, developers add, save, or remove changes accordingly multiple times. Most of the time, developers add changes in one branch and, without saving it into the repository, want to switch branches. In that situation, the Git feature named “Stash” temporarily holds the changes. Moreover, it saves the index along with the working directory. Additionally, developers can view the stash contents by running the “$ git stash list” command.

This blog will elaborate on the procedure to display what’s in a stash without applying it.

How to Display What’s in a Stash Without Applying It?

To view what the stash contains, try out provided instructions:

  • Move to Git local repository.
  • Display the repository content.
  • Open the desired file, add changes, and save it.
  • Temporarily save the changes and index into stashes.
  • See the list of stashes.

Step 1: Go to Git Repository
First, go to the Git repository by utilizing the mentioned below command:

$ cd "C:\Users\nazma\Git\Test_9"

Step 2: View the List of Repository Content
Then, execute the “ls” command to display the list of repository content:

$ ls

Step 3: Update Existing File
Next, update desired existing text file by running the “start” command:

$ start file1.txt

The specified file will be opened with a default text editor, add changes, save them, and close the file:

Step 4: Add Changes Into Stash
Now, run the provided command to save the working directory and index state into stash:

$ git stash

Step 5: Display Stash Without Applying It
Finally, to view the stash without applying it, run the “git stash list” command:

$ git stash list

That’s all! We have explained the procedure to view what’s in a stash without applying it.

Conclusion

To see what’s in a stash without applying it, go to Git’s local repository, view the repository list of content, and update the desired file from the existing content. Then, save the working directory with added changes and index it into the stash. Lastly, execute the “$ git stash list” command. This blog provided a method to see what’s in a stash without applying it.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.