Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git stash apply and drop

Tags:

git

Is there a git command that both applies the stash and removes it?

This as one command:

git stash apply git stash drop 
like image 935
Kirk Strobeck Avatar asked Feb 08 '13 17:02

Kirk Strobeck


People also ask

How do I drop a git stash?

To drop a particular stash, click on Delete Stash button and give confirmation to delete (drop) it.

Does git stash apply?

You can reapply stashed changes with the commands git stash apply and git stash pop . Both commands reapply the changes stashed in the latest stash (that is, stash@{0} ). A stash reapplies the changes while pop removes the changes from the stash and reapplies them to the working copy.

Does git stash apply remove stash?

The key difference between git stash pop and apply involves the stash history. When a developer uses the git stash apply command, the most recently saved stash overwrites files in the current working tree but leaves the stash history alone. In contrast, the pop command restores files but then deletes the applied stash.

What does apply stash mean?

Stashing your work The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy. For example: $ git status On branch main Changes to be committed: new file: style.


2 Answers

You want git stash pop!

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. 
like image 63
Adam Wright Avatar answered Oct 06 '22 14:10

Adam Wright


git stash pop will take the first stash in your list (or the one you specify), apply it to your HEAD, and delete it from the stash list.

like image 28
ellotheth Avatar answered Oct 06 '22 12:10

ellotheth