git stash -k
Stashes changes in the working directory, but keeps the untracked files
This command temporarily shelves uncommitted changes, including new files, while keeping changes that have been added to the index (staging area).
The -k
flag keeps the index untouched while stashing only the working directory changes. This is useful if you want to stash only the unstaged changes.
Variations of the command include using -u
to stash untracked files as well or -a
to stash all files including those ignored by .gitignore
.