Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply and drop my latest git stash in the same command?

Tags:

git

It appears that when I do git stash apply, I need to then type in git stash drop in order to remove that stash from the available stashes. Can I do this in one command?

like image 217
Rebekah Waterbury Avatar asked Dec 11 '25 09:12

Rebekah Waterbury


1 Answers

git stash pop is what you're looking for. As the man page says:

pop [--index] [-q|--quiet] [<stash>]

    Remove a single stashed state from the stash list and apply it on
    top of the current working tree state, i.e., do the inverse operation
    of git stash save. The working directory must match the index.

    Applying the state can fail with conflicts; in this case, it is not
    removed from the stash list. You need to resolve the conflicts by hand
    and call git stash drop manually afterwards.
like image 101
Ventero Avatar answered Dec 12 '25 23:12

Ventero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!