git stash untracked files

2021-11-29

 | 

~1 min read

 | 

104 words

By default, Git’s stash command will only stash the uncommitted changes to tracked files, i.e., files that have already been included in the commit history.

So, what happens if you start down a path, create a bunch of files and then need to change direction? Git stash won’t work - all of the new files will just be skipped.

To include these new files use the --include-untracked (-u) option.

% git stash --include-untracked

or

% git stash -u

It’s worth noting, however, that if only untracked files are included, the stash can appear empty if you run git stash show.



Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!