DEV Community

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

Collapse
 
deciduously profile image
Ben Lovy

git stash - e.g. git stash . or git stash src/index.js. Then git stash apply to apply the stashed changes or git stash drop to discard them.

Is that what you're looking for?

Collapse
 
ryzngard profile image
Andrew Hall

git stash pop is like apply + drop as well. I think git stash --keep-index keeps everything staged, and stashes unstaged changes. Useful if it's hard to type the pathspec for multiple files, or if you want to stash some changes to a file but not all.

Collapse
 
andy profile image
Andy Zhao (he/him)

Big fan of git stash pop. Definitely a 1 command > 2 commands scenario.

Thread Thread
 
deciduously profile image
Ben Lovy

Whoa, TIL. Git's pretty cool, isn't it