Skip to main content

Which changes go into stash?

By default, stash captures uncommitted changes, but not all types of files.


What is saved to stash by default

When you run:

bash
git stash

The stash captures:

  • changes to tracked files in the working directory
  • changes in the staging area

What is NOT captured by stash by default

  • untracked files
  • files ignored via .gitignore

How to add untracked files

bash
git stash -u

or

bash
git stash --include-untracked

In this case, the stash captures:

  • tracked files
  • untracked files

How to add everything, including ignored files

bash
git stash -a

or

bash
git stash --all

Summary table

Type of changeBy default-u-a
Tracked filesyesyesyes
Staged changesyesyesyes
Untracked filesnoyesyes
Ignored filesnonoyes

Key phrasing for an interview

By default git stash saves the changes of tracked files from the working directory and staging area. Untracked and ignored files are not included unless the corresponding options are specified explicitly.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.