Git Stash

Fri 06 August 2021

If you just quickly want to create a temporary stash:

git stash
# .. do your thing
git stash pop

This create and applies a stash, if you want to manage multiple stashes however, the following process is recommended:

[A] Create stash

git stash push -m "stashname"

Or simply use git stash in case you don't care about the additional message. The stash will then be created with a message like "WIP on branchname ...".

[B] Retieve stash**

git stash list

stash@{0}: On develop: perf-spike
stash@{1}: On develop: node v10

Then you simply use apply giving it the stash@{index}:

git stash apply 1

When using apply the state is not removed from the stash list, if in addition to applying the stash, you also want to remove the stashed state from the stash list use:

git stash pop 1

Category: Git