How do you stash only specific files or include untracked files when stashing?

Last updated 6 July 2026

  • git stash push <paths> stashes only the listed files (add -m for a message), and -p lets you pick individual hunks.

  • Untracked files are skipped by default. Use -u (--include-untracked) to include them.

  • -a (--all) also stashes files ignored by .gitignore.

  • https://git-scm.com/docs/git-stash
  • https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning
  • https://dev.to/mrsaynothing/git-stash-a-single-file-without-losing-the-rest-4jcn
  • https://betterstack.com/community/questions/git-stahs-specific-file/
  • https://www.geeksforgeeks.org/git/how-to-stash-an-untracked-file-in-git/
All Git interview questions