Cheat Sheets · Git Cheat Sheet · Git Stash Untracked Files (-u and -a Flags)

Git Stash Untracked Files (-u and -a Flags)

git stash

Yes

git stash -u (--include-untracked)

Yes

git stash -a (--all)

Yes

Stash scope comparison

CommandTracked ModifiedUntracked NewIgnored (.gitignore)
git stashYesNoNo
git stash -u (--include-untracked)YesYesNo
git stash -a (--all)YesYesYes

By default, git stash ignores new files that have not been staged. Use the -u flag to stash new files alongside your tracked changes.

Related Git recipes

FAQ

Why didn't plain git stash save my new files?
Plain git stash only tracks files Git is already monitoring. Always use git stash -u when working with new files.

When should I use -a instead of -u?
Only when you want to stash files listed in .gitignore (like node_modules or .env). Usually -u is what you want.

How to name a stash with untracked files?
Combine options: git stash push -u -m "wip: new components".

Stop memorizing — build it interactively

Try stash options in the Git Builder

Full reference: Git Cheat Sheet