git stash --include-untracked

Let’s say you have modified a file in a git repository and have also created a new file, but not added it to the repository yet:

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   README.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    notes.txt

no changes added to commit (use "git add" and/or "git commit -a")

If you run git stash, the untracked file remains in the working copy:

$ git stash
Saved working directory and index state WIP on master: 0f25a2b Initial commit
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    notes.txt

nothing added to commit but untracked files present (use "git add" to track)

Chances are the untracked files are related to the change you are trying to make and would like to bundle them in that stash.

The --include-untracked option (or -u in its short version) allows you to do just that:

$ git stash -u
Saved working directory and index state WIP on master: 0f25a2b Initial commit
$ git status
On branch master
nothing to commit, working tree clean

That’s a nice alternative to adding the untracked files and making a “work in progress” commit.