Git
Git stash
Version control
Git commands
Git tips

How can I delete all of my Git stashes at once?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Git stash is useful for short-lived context switches, but stash entries tend to pile up when they are treated as long-term storage. Deleting them all is easy, but it is also destructive, so the safe workflow is inspect first, preserve anything important, and only then clear the list.

Use git stash clear To Remove Everything

Git provides a direct command to delete every stash entry at once.

bash
git stash clear

That command empties the stash list completely. A quick before-and-after check makes the result obvious:

bash
git stash list
git stash clear
git stash list

Because this is destructive, do not run it reflexively in a repository where you have not reviewed the existing stash entries.

Inspect the Stash List Before Deleting

Start by seeing what is actually stored.

bash
git stash list

If an entry looks unfamiliar or important, preview it before deleting:

bash
git stash show -p stash@{0}

This is especially useful when older stash entries contain work you forgot about or when stash messages were vague and you need to confirm the contents.

Preserve Important Work Before Clearing

If one stash still matters, convert it into a safer form before you clear everything. One good option is to create a branch directly from a stash:

bash
git stash branch recover/feature-work stash@{0}

Another option is to apply the stash to a new branch and commit it explicitly:

bash
1git switch -c recover/manual
2git stash apply stash@{1}
3git add -A
4git commit -m "Recover stash before cleanup"

Branches and commits are much safer for anything you might need later than keeping the work hidden in the stash stack.

Prefer Selective Cleanup When Appropriate

If you only want to remove some stashes, use drop instead of clearing the whole stack.

bash
git stash drop stash@{2}
git stash drop stash@{0}

Be careful here because stash indices shift after each drop. Re-run git stash list between deletions instead of assuming the numbers stay stable.

If you want to apply and remove the most recent entry in one step, pop is often the better command:

bash
git stash pop stash@{0}

Treat Stash as Temporary, Not Archival

A healthy Git workflow uses stash for short interruptions, not as a long-term backlog. If you regularly discover months-old stashes, that is usually a sign that the changes should have been moved into branches much earlier.

A useful rule of thumb is:

  1. stash for quick interruptions
  2. branch and commit for anything you may revisit later

That habit makes cleanup much less risky and drastically reduces the chance of losing useful work during stash maintenance.

Understand Recovery Limits

After git stash clear, recovery is uncertain and not something you should count on in normal workflow. Git may still retain unreachable objects for a while, but there is no simple, guaranteed restore command for a cleared stash list.

That is why you should treat git stash clear as effectively irreversible unless you have already preserved the work elsewhere.

Add Safer Habits for Future Cleanup

Two small practices make stash management safer:

  1. use descriptive stash messages
  2. review the stash list periodically instead of letting it rot

Creating named stashes helps a lot:

bash
git stash push -u -m "wip api pagination fix"

Clear messages make it much easier to decide what can be deleted and what deserves to be recovered into a branch.

Common Pitfalls

The most common mistake is running git stash clear without checking the stash list first. Another is assuming stash contents are backed up remotely, which they are not. Developers also misuse stash as a long-term storage mechanism and only realize the risk when cleanup time comes.

Summary

  • Use git stash clear to delete all stash entries at once.
  • Inspect and preview stash contents before destructive cleanup.
  • Recover anything important into a branch or commit before clearing.
  • Use drop or pop when selective cleanup is safer than clearing everything.
  • Treat stash as temporary storage, not as a hidden long-term archive.

Course illustration
Course illustration