Skip to main content
Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How to Use Git Stash: Save, List, Apply, and Drop Changes

There are lots of situations where a clean working copy is recommended or even required: when merging branches, when pulling from a remote, or simply when checking out a different branch.

The git stash command lets you temporarily but safely store your uncommitted local changes — leaving you with a clean working copy so you can switch contexts freely.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

When to Use git stash

Scenario Why stash helps
Switching branches mid-work You need a clean working copy to check out another branch
Pulling remote changes Your local edits conflict with incoming changes from git pull
Testing a clean state You want to verify something works without your uncommitted changes
Quick experiments You want to try something without committing unfinished work

Saving Changes with git stash

Let's say you currently have a couple of local modifications:

$ git status
  modified:   index.php
  modified:   css/styles.css

If you have to switch context — e.g. because you need to work on an urgent bug — you need to get these changes out of the way without committing unfinished work. This is where git stash comes in handy:

$ git stash
Saved working directory and index state WIP on master:
   2dfe283 Implement the new login box
HEAD is now at 2dfe283 Implement the new login box

Your working copy is now clean. You're ready to start your new task.

Add a descriptive message with git stash push -m to make entries easier to identify later:

$ git stash push -m "login feature WIP"

Restoring Changes: git stash pop and apply

When you're ready to continue where you left off, restore the saved state with git stash pop:

$ git stash pop

pop reapplies the most recent stash entry and removes it from the stack. To apply a specific entry (not the most recent), provide its index:

$ git stash pop stash@{2}

Note: There is no git unstash command. To restore stashed changes, always use git stash pop or git stash apply.

If you want to restore your changes but keep them on the stack (e.g. to apply the same changes to multiple branches), use apply instead:

$ git stash apply
Command Restores changes Removes from stack
git stash pop Yes Yes
git stash apply Yes No

You can also preserve your staged files in the working directory while stashing everything else:

$ git stash push --keep-index

Listing and Inspecting Stash Entries

When you accumulate multiple stashes, git stash list shows them all:

$ git stash list
stash@{0}: On main: New sidebar
stash@{1}: On main: Blog template
stash@{2}: On feature/affiliate-program: Affiliate Program page
stash@{3}: WIP on main: c953ca6 Add HTML boilerplate

You can limit the number of entries shown, filter by date, or search by message:

$ git stash list --3                        # show last 3 entries
$ git stash list --before 10.days.ago
$ git stash list --grep "login"

To inspect what's actually in a stash entry before applying it, use git stash show:

$ git stash show stash@{2}                  # summary of changed files
$ git stash show -p stash@{2}               # full diff
$ git diff stash@{1} main                   # compare stash against a branch


Tip

Managing Stashes in Tower

If you are using the Tower Git client, you can manage all your stash entries and inspect their diffs from the "Stashes" view in the sidebar:

Tower — Stashes View

Does git stash Include Untracked Files?

By default, git stash only saves changes to tracked files. New files that haven't been added to Git yet (untracked files) are left behind.

To include untracked files, use the -u flag:

$ git stash -u

To also stash ignored files (e.g. build artifacts), use -a:

$ git stash --all

Autostash limitation: The --autostash option used with git pull or git rebase runs a plain git stash internally — it does NOT include untracked files. If you have untracked files that conflict, stash them manually first:

$ git stash -u
$ git pull --rebase
$ git stash pop

Stashing Specific Files

To stash only certain files, pass their paths after --:

$ git stash push -m "just the CSS" -- css/styles.css
$ git stash push -- file1.js file2.js

For interactive control over which changes to stash, use --patch:

$ git stash push --patch

Troubleshooting: "No Local Changes to Save"

If git stash reports no changes to save, one of two things is likely happening:

1. You only have untracked (new) files. A plain git stash ignores them. Use -u:

$ git stash -u

2. Your changes are in ignored files. Files listed in .gitignore are also skipped by default. Use -a:

$ git stash --all


Tip

Using the Stash in Tower

In case you are using the Tower Git client, saving to and restoring from the Stash can be performed right from the toolbar. Tower even lets you restore the exact state of your Working Copy when you restore a Stash:


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.