by Sai gowtham

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

  1. Run the below command to get the list of available stashes in your repository.
git stash list
  1. Choose a stash index you want to delete.
  2. 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}.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course