Stashing takes the dirty state of your working directory – that is, your modified tracked files and staged changes – and saves it on a stack of unfinished changes that you can reapply at any time.
Stashing only modified files:
Suppose you don't want to stash the staged files and only stash the modified files so you can use:
git stash --keep-index
Which will stash only the modified files.
Stashing untracked files:
Stash never saves the untracked files it only stashes the modified and staged files. So suppose if you need to stash the untracked files too then you can use this:
git stash -u
this will track the untracked, staged and modified files.
Stash some particular changes only:
Suppose you need to stash only some part of code from the file or only some files only from all the modified and stashed files then you can do it like this:
git stash --patch
Git will not stash everything that is modified but will instead prompt you interactively which of the changes you would like to stash and which you would like to keep in your working directory.