How do I delete all Git stashes?

This translation from: How the I CAN the Delete All of My Git stashes AT Once?

All of the I CAN the Delete How My Git stashes AT Once? How do I delete all Git stashes?

Specifically I mean, with typing in one command. Specifically, I mean, enter a command.


#1st Floor

Reference: https://stackoom.com/question/lhh1/ How do I delete all Git-stashes


#2nd Floor

The following command deletes all your stashes: The following command to delete all stored:

git stash clear

At The the From git Documentation : From the git documentation :

clear

Remove all the stashed states. Delete all hidden.

The WARNING IMPORTANT: Those States by Will BE Subject to the then Pruning, and May BE Impossible to Recover (...). IMPORTANT WARNING: These states will be trimmed, may not recover (......).


#3rd floor

There are two ways to delete a stash : Delete stored in two ways:

  1. A longer need you NO IF Particular stash, you CAN IT with the Delete: $ git stash drop <stash_id>. If you no longer need special storage, you can use the following command to remove it: $ git stash drop <stash_id>.
  2. All of your CAN the Delete by You from stashes at The repo with: $ git stash clear. You can delete all from the repurchase use the following command $ git stash clear: $ git stash clear.

Use both of them with caution, it maybe is difficult to revert the once deleted stashes. Prudent to use them, it may be difficult to recover the stash had been deleted.

At The IS here Wallpaper Reference Article This article was . This is a reference article .


#4th floor

this command enables you to look all stashed changes. Use this command to view all the hidden changes.

git stash list

Here is the following command use it to clear all of your stashed Changes following commands use it to remove all the hidden changes

git stash clear

Now if you want to delete one of the stashed changes from stash area now, if you want to delete one of the hidden area hidden changes

git stash drop stash@{index}   // here index will be shown after getting stash list.

Note: git stash listthe Enables you to GET index from stash Area of git. Note: git stash listallows you to get an index from the git stash area.


#5th Floor

I had another requirement like only few stash have to be removed, below code would be helpful in that case. I have another requirement, for example, only need to remove a small amount of storage, the following code in this case will help.

#!/bin/sh
for i in `seq 5 8`
do
   git stash drop stash@{$i}
done

/ * By Will the Delete from 5 to 8 index * / / * will delete 5-8 index * /


#6th floor

I wanted to keep a few recent stashes , but delete everything else. I want to keep some of the recent stash, but delete everything else.

Because all stashes get renumbered when you drop one, this is actually easy to do with while. Because when you leave a time, all the stash will be renumbered, which is actually very easy. To delete all stashes older than stash @ {19}: Delete {19} older than all the stash stash @:

while git stash drop 'stash@{20}'; do true; done
Original articles published 0 · won praise 136 · views 830 000 +

Guess you like

Origin blog.csdn.net/xfxf996/article/details/105248816