Multiple git stashes

Did you know git can keep multiple stashes? If you use git stash and git stash apply, you might be tempted to think there is a single stash, but you can restore older stashes, and thus stash multiple items.

To see your previous stashes, use git stash list. You will get a result like this:

stash@{0}: WIP on master: 6c483e2 Updated location.search to use empty string instead of null
stash@{1}: WIP on master: 6c483e2 Updated location.search to use empty string instead of null
stash@{2}: WIP on master: 142e661 Removed middle state for the search results panel
stash@{3}: WIP on master: 0e65041 Added spinner to search
stash@{4}: WIP on master: 723eef5 Put the search query in the search service
...

To restore a particular stash, use git stash apply stash@{0} and replace 0 with the index of the stash you wish to restore.

Use git stash clear to erase all your stashed changes.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax