talles
talles

Reputation: 15086

Applying several stashes without commiting

Is there anyway to apply various stashes in my currently checked out branch without having to do commits (and eventually resetting HEAD) in the process?

Upvotes: 0

Views: 64

Answers (1)

iberbeu
iberbeu

Reputation: 16185

There is no trick: just apply the stashes one after another.

If your stashes are correctly ordered in the stack you just need to proceed as follows:

git stash apply
git stash drop

Repeat this until you apply all stashes you need. You don't need to commit between apply and apply. If you want to save time a better command can be used: instead of first apply and then drop you can just pop the stash

git stash pop

If the stashes are not in a proper order then specify in the command which stash you want to apply or drop:

git stash apply <stash>
git stash drop <stash> 

or

git stash pop <stash> 

If you the stash apply gives a merge error it means that you are not allowed to apply this stash. So in that case you cannot apply it until you commit your changes. It is maybe ugly but it is the waz it works.

Upvotes: 2

Related Questions