This message appears when running git stash but Git finds no modified tracked files in your working directory. It typically occurs when you have only untracked files, or your working directory is already clean.
When Git displays "No local changes to save," it means the stash command found nothing to stash. By default, `git stash` only saves changes to files that Git is already tracking (files that have been previously committed or staged). This is not an error in the traditional senseβit is informational feedback. Git is telling you that your working directory has no modifications to tracked files that need to be temporarily stored. The most common scenario is when you have created new files but haven't staged them yet. These untracked files are invisible to the default stash operation. Similarly, if you already committed or stashed all your changes, your working directory will be clean and there will be nothing left to stash.
First, verify what Git sees in your working directory:
git statusIf the output shows "nothing to commit, working tree clean," your directory truly has no changes to stash. If you see files listed under "Untracked files," those are the files being ignored by the default stash command.
To stash untracked files (new files you haven't added yet), use the -u or --include-untracked flag:
git stash -u
# or
git stash --include-untrackedThis tells Git to also stash files that are not yet tracked.
Alternatively, you can stage your new files first, then stash:
git add .
git stashOnce files are staged, they are considered "changes" that git stash will pick up.
If you also need to stash files that are in your .gitignore, use the -a or --all flag:
git stash -a
# or
git stash --allThis stashes tracked changes, untracked files, AND ignored files. Use with caution as it may include build artifacts or dependencies.
After running the appropriate stash command, confirm it worked:
git stash listYou should see an entry like stash@{0}: WIP on main: abc1234 Your last commit message.
### Understanding Git Stash Behavior
The stash command creates a commit-like object that stores your working directory state. By default, it only considers:
- Modified tracked files (changes not yet staged)
- Staged changes (in the index)
It explicitly excludes:
- Untracked files (unless -u is used)
- Ignored files (unless -a is used)
### Stash with a Message
When stashing, it helps to add a descriptive message:
git stash push -u -m "WIP: feature X before switching branches"### Partial Stashing
You can stash specific files only:
git stash push -u path/to/file.js another/file.ts### Scripting Considerations
If you are writing scripts that use git stash, check the exit code. Git returns exit code 0 even when "No local changes to save" is printed. To detect this programmatically, check if a new stash was created by comparing git stash list before and after, or use git stash push and check if the stash ref changed.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server