How to Drop Stash in Git: Simple Commands Explained
To drop a stash in Git, use the command
git stash drop [stash@{index}] to remove a specific stash or git stash clear to remove all stashes. Dropping a stash deletes it permanently from your stash list.Syntax
The basic command to drop a stash is git stash drop [stash@{index}]. If you omit the stash reference, Git drops the latest stash by default. To remove all stashes at once, use git stash clear.
git stash drop stash@{0}: Drops the stash at index 0 (the most recent stash).git stash drop: Drops the latest stash if no index is given.git stash clear: Removes all stashes permanently.
bash
git stash drop [stash@{index}]
git stash clearExample
This example shows how to list stashes, drop a specific stash, and then verify it is removed.
bash
git stash list # Output shows stashes with indexes # Drop the stash at index 1 git stash drop stash@{1} # Verify the stash is removed git stash list
Output
stash@{0}: WIP on main: 123abc Fix typo
stash@{1}: WIP on main: 456def Add feature
Dropped stash@{1} (456def Add feature)
stash@{0}: WIP on main: 123abc Fix typo
Common Pitfalls
One common mistake is dropping a stash without specifying the correct index, which may remove the wrong stash. Another is forgetting that git stash clear deletes all stashes permanently and cannot be undone.
Always check your stash list with git stash list before dropping.
bash
git stash drop
# Drops the latest stash, but you might want to drop a different one
# Correct way:
git stash drop stash@{2}
# To avoid accidental loss, verify first:
git stash listQuick Reference
| Command | Description |
|---|---|
| git stash drop stash@{index} | Remove a specific stash by index |
| git stash drop | Remove the latest stash if no index given |
| git stash clear | Remove all stashes permanently |
| git stash list | Show all current stashes |
Key Takeaways
Use
git stash drop stash@{index} to remove a specific stash safely.Omitting the stash index drops the latest stash by default.
git stash clear deletes all stashes and cannot be undone.Always check your stash list with
git stash list before dropping.Dropping a stash permanently deletes saved changes, so be cautious.