Reputation: 2563
I made a stash of multiple files (30 +) using git stash. I now want to apply the stash to all files except one. What is the best way to achieve this?
Upvotes: 7
Views: 8090
Reputation: 9692
You can stage the file you want to preserve by doing
git add <file>
and then use
git stash push --keep-index
This will stash everything but staged files.
Upvotes: 8
Reputation: 338
Your best bet is to probably to git stash apply
then git checkout -- [file]
to remove the changes applied when applying the stash.
If you have changes in the file already, your best bet is to commit them before applying the stash, you could then rebase the commit and the stash into a single commit later if you wished.
Upvotes: 10
Reputation: 29
I have a workaround answer. Commit the file. Git stash. Revert the commit.
Upvotes: 2