Cancel "git stash --patch"
I ran "git stash -p" (equivalent to "git stash --patch"), which successfully hid some of the changes I made to the code. When I tried to run "git stash pop" it gave me the following message:
Error: Your local changes in the following files will be overwritten with merge:
[list of files]
Please make your changes or copy them before you can merge.
Aborting
How can I get all my changes back? This question has a method (haven't tried it yet) but I was hoping for something cleaner and simpler.
+3
source to share
1 answer
I'm just into the same problem. Here's what I did:
$ git stash --patch
# now you have a 'partial' stash
#
# commit all changes in your working tree
$ git add .
$ git commit -m TEMP
# pop the stash
$ git stash pop
# now your stashed changes have been applied successfully
#
# reset your working tree to the original state
$ git reset --soft HEAD^^
# optionally reset your index
$ git reset .
This resets the working tree to state git stash
. Changes to your index will be lost.
+1
source to share