By default, the git stash push and save commands will only save files that have either been added to the Git index or are part of the Git commit message history. If a file is added to the local working tree but remains untracked by the Git framework, it will not be added. But it is possible to alter this behavior and stash untracked files with the right git stash save and push options.

The trick is to use the –include-untracked option or for brevity, the –u alias.

It’s worth noting that no matter which switch is used, after a developer invokes git stash, untracked files are immediately deleted from the working tree. This is due to the fact that both a hard reset and a file-system clean occurs behind the scenes after a git stash. A developer might find that behavior mildly disconcerting if it wasn’t expected.

/git stash untracked files
$ git stash push --include-untracked
$ git stash push –u
$ git save...



News Source