How to delete a stash in Git
In this tutorial, we are going to learn about how to delete a stash in git with the help of examples.
Deleting All Stashes
To delete all stashes in git, we need to run the git stash command followed by the clear
option.
Example:
git stash clear
Note: Once you run the above command it is impossible to recover the stash entries.
Deleting a Particular Stash
- Run the below command to get the list of available stashes in your repository.
git stash list
-
Choose a stash index you want to delete.
-
Now, run the git stash command followed by the
drop
option and your stash index.
git stash drop stash@{2}
# stash@{index-number}
Note: If a stash index is not provided it will delete a recently created stash that is
stash@{0}
.