How to List Git Stash Entries

October 4, 2022


A Git stash allows you to hide unfinished work from the current working directory and return to it later. There is no limit to the number of Git stashes you can create, which means the stash reference can hold multiple entries.

In this tutorial, you will learn to view Git stash entries.

How to View Git Stash Entries


What is Git Stash List?

Creating a stash using the git stash command sets aside the uncommitted changes and reverts the working directory to match the HEAD commit. Git allows users to create as many stashes as needed.

When creating a stash using the git stash command, the changes are saved in the refs/stash reference. Each stash entry is assigned an index number, where the latest entry is stash@{0}, then comes stash@{1}, and so on.

A Git stash list shows the existing stash entries, the name of the branch on which the entry was created, and a description of the commit the entry is based on.

How to Use Git Stash List?

Running the git stash list command outputs a list of all the stashes you created. Customize the output by specifying options applicable to the git log command. The options provide many enhancements and formatting options.

The sections below showcase different examples of using the git stash list command and the available options.

View the Git Stash History

See the Git stash history by running the default list command without options. The command outputs the entire stash history.

Run the following command:

git stash list
Listing all stashes in the reference.

The most recent stash has the index {0}. Additionally, if specified during creation, the output contains a message for each stash. If there is no stash message, the output shows the message related to the commit the stash is based on. 

See Stashes Attached to All Branches

Use the --all option to display stashes attached to all branches instead of only showing the currently active one. Run the following command:

git stash list --all
Showing stashes attached to all branches in the repository.

The partial output above shows stashes from all Git branches in the repository.

Show Limited Number of Stashes

If you have a long git stash history with many stash entries, specify a limited number of the most recent stashes to show in the output.

The syntax is:

git stash list -[n]
  • For [n], specify the number of stashes to show in the output.

For example, to show the two most recent stash entries, run:

git stash list -2
Outputting a limited number of stashes.

View Stashes By Date

Use the --after option followed by date to show only the stashes more recent than the specified date. Alternatively, use the --before option to show only the stashes older than the specified date.

The accepted date formats are:

  • Mon, 5 Jul 2022 17:18:43 +0200
  • 2022-07-05 17:18:43 +0200
  • Mon Jul 5 15:18:43 2022
  • 2022-07-05
  • 5.hours.ago
  • 3.years.2.months.ago
  • 6am yesterday

For example, to show only the stashes older than five days, enter:

git stash list --before 5.days.ago
Viewing Git stashes by date.

The output contains only one stash, which was created more than five days ago.

See Stash Contents

After listing the stash history, see the contents of a specific stash using the show command. The syntax is:

git stash show stash@{n}
  • For {n}, specify the stash index whose contents you want to see.

For example, to view the contents of stash{0}, run:

git stash show stash@{0}
Showing a Git stash's contents.

The output shows the stashed files, along with the number of file insertions and deletions.

Note: Untracked files are excluded from Git stashes unless you specifically instruct to include them. See how to stash untracked files and then view the stash contents.

View the Changes in Git Stash Entries

Specify the -p option to view the diff of changes for each stash. Run the following command:

git stash list -p
Viewing the diffs for each stash in the Git stash history.

The partial output above shows the diffs for stash{0}. To see other stash diffs, scroll through the terminal window.

Alternatively, to see the difference between a stash and the local Git working tree, specify the stash you want to compare.

The syntax is:

git stash show -p stash@{n}

See Stats for Stashed Files

Specify the --stat option to output a summary of changes for each file in the Git stash history. Run the following command:

git stash list --stat
Showing the stats for Git stashes.

The command outputs the number and summary of changes for the files in each stash.

Show Detailed Stash List

For a concise Git stash list with more details about each stash, specify the --oneline option with the list command. Enter the following:

git stash list --oneline
Viewing a Git stash list in more detail.

The command outputs a list of stashes, the stash commit SHA, the stash paths, and a message created for the stash, or commit message the stash is based on.


This tutorial showed how to list Git stash entries in a repository and utilize different command options to format and customize the output.

Learn more about Git in our tutorials for restoring a Git stash, dropping a Git stash, or stashing specific files.

Was this article helpful?
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How Does Git Work?
September 16, 2021

Git is the world's most popular version control system. This article showcases how Git works and explains each Git function in detail.
Read more
How to Use Git {Beginner's Guide}
September 2, 2021

Learn to use Git effectively with this step-by-step beginner's guide that covers the basic Git functions.
Read more
How to Name a Stash and Retrieve a Stash by Name in Git
September 27, 2022

This tutorial shows how to add a custom name or message to a stash, and later retrieve the stash using that name.
Read more
How to Git Stash Specific Files
September 13, 2022

This tutorial shows how to stash a specific file using Git. Stashing is a great way of putting aside unfinished changes that aren't yet ready to be committed.
Read more