Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

Does git stash save untracked files, and how do you include them?

SHORT ANSWER

By default git stash saves only tracked changes. Add -u (--include-untracked) to also stash new files, or -a to include ignored files as well.

Explain it simply

You are halfway through a new page, contact.html, and need to switch branches urgently. You run git stash, switch, and later find contact.html still sitting there. Stash ignored it, because Git does not track it yet.

git stash -u includes untracked files, and git stash -a includes ignored ones too, which can sweep up large folders like node_modules. Alternatively, git add the new file first, which makes it tracked, and the plain stash takes it.

Example

bash
git stash -u -m "contact page wip"
git switch hotfix/login
# ... fix, commit, push ...
git switch -
git stash pop

What to say in the interview

"Plain stash covers only tracked files. I use git stash -u to include untracked files, and avoid -a unless I really need ignored files. Adding the new file first also works."

#git#stash#untracked

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.