β git: stash untracked files
β’ 187 words β’ 1 min β’ updated
As I write this very post, this is what my git repository status looks like:
shell
% git st
## master...origin/master
?? content/posts/2025-12-22-git-stash-untracked.mdWhat if I wanted to stash it?
shell
% git stash
No local changes to save
% git st
## master...origin/master
?? content/posts/2025-12-22-git-stash-untracked.mdNothing happens, because this post is a new file, not yet tracked by git.
The classic way to address this is to switch to another branch, commit
everything (e.g. with git-freeze), and then switch back. But this is slow.
Today I learned about git stash -u:
-u, --include-untracked, --no-include-untracked
When used with the push and save commands, all untracked files are also stashed and then cleaned up with git clean.
When used with the show command, show the untracked files in the
stash entry as part of the diff.Let’s try it:
shell
% git stash -u
Saved working directory and index state WIP on master: 58cde6e88 hide codeblock header in RSS feeds
% git st
## master...origin/masterThe new post gets stashed indeed!
I don’t know how I missed this feature β I’ve wanted this functionality for
stash since forever!
Backlinks
- git: diff untracked (Jan 04, 2026)