Cheat Sheets · Git Cheat Sheet · Git Stash Untracked Files (-u and -a Flags)
Git Stash Untracked Files (-u and -a Flags)
git stashYes
git stash -u (--include-untracked)Yes
git stash -a (--all)Yes
Stash scope comparison
| Command | Tracked Modified | Untracked New | Ignored (.gitignore) |
|---|---|---|---|
git stash | Yes | No | No |
git stash -u (--include-untracked) | Yes | Yes | No |
git stash -a (--all) | Yes | Yes | Yes |
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
Undo Last Commit — 3 Safe Ways
Discard Local Changes — Safely and Completely
Delete a Branch — Local and Remote
Stash — Park Changes Without Committing
Amend the Last Commit
Undo a Pushed Commit — The Safe Way (git revert)
Rename Local Branch — Safely & Quickly
Rename Remote Branch — Complete 3-Step Process
Cherry Pick — Apply a Specific Commit Elsewhere
Squash Last N Commits — Combine Multiple Commits
Sync Fork with Upstream — Step-by-Step
Delete Remote Tag — Local and Remote
Change Commit Author — Email & Name
Unstage File — Remove from Staging Area
Log Graph — Visual Commit History in Terminal
Clean Untracked Files — Remove Clutter Safely
Switch Branch — Modern Branch Navigation
Create Branch from Commit — Branch Off History
Force Pull — Overwrite Local Changes with Remote
Resolve Merge Conflict — Complete Workflow
Show Commit — Inspect Changes in a Commit
Tag a Release — Lightweight & Annotated Tags
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 BuilderFull reference: Git Cheat Sheet