There's more...

In the preceding example, we saw only the very basic usage of the stash command, putting away changes to untracked files and changes added to the staging area. It is also possible to include untracked files in the stash command. This can be done with the --include-untracked option. We can add foo to the staging area; firstly, to have the same state as when we created the stash earlier and then to create a stash that includes untracked files:

$ git add foo
$ git stash --include-untracked
Saved working directory and index state WIP on master: 691808e Update foo
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
    
nothing to commit, working directory ...

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.