Does Git Stash Save Unstaged Files?

Does Git Stash Save Unstaged Files?

By default git ignores untracked files when doing stash. If those files need to be added to stash you can use -u options which tells git to include untracked files. Ignored files can be added as well if -a option is specified.

Does git stash work on unstaged files?

The marked answer, git stash --keep-index , stashes both the staged and unstaged changes. The --keep-index part merely leaves the index intact on the working copy as well.

Can I stash unstaged files?

If you have both staged and unstaged changes in your project, you can perform a stash on just the unstaged ones by using the -k flag. The staged changes will be left intact ready for a commit.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.