DEV Community

Discussion on: How to stash a specific file or multiple files?

Collapse
 
chhajedji profile image
chinmay chhajed

git stash --keep-index it is.

Add the changes to the staging area which you do not want to stash. All changes to be stashed should be not staged but modified or untracked. Then you can just git stash --keep-index to stash changes. As mentioned in some other answer, add -u to add untracked files also. Then you can just git restore --staged <file names> to bring staged changes back to modified.