How to do it...

To save the current state to a stash with a description we can remember at a later point in time, use the following command:

$ git stash save 'Updates to foo'
Saved working directory and index state On master: Updates to foo

Our stash list now looks like the following:

$ git stash list
stash@{0}: On master: Updates to foo
stash@{1}: WIP on master: 2302181 Update foo

We can change bar and create a new stash:

$ echo "Another change" >> bar
$ git stash save 'Made another change to bar'
Saved working directory and index state On master: Made another change to bar
$ git stash list
stash@{0}: On master: Made another change to bar
stash@{1}: On master: Updates to foo
stash@{2}: WIP on master: 2302181 Update foo

We can apply the stashes ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.