We've done something bad.
We ran git stash save
during a merge conflict, and now we can't restore our work.
Things we've tried:
git pull -Xours origin master
git stash apply --index
And:
git pull origin master
git stash save --keep-index "merge conflicts"
git stash apply stash@{1}
Please help!
The issue seems to be that git stash
doesn't save a reference to the branch you were trying to merge in. During a merge, this is stored in a ref named MERGE_HEAD
.
To fix it and get back to your previous state, you need to find the revision (let's pretend it's d7a9884a380f81b2fbf002442ee9c9eaf34ff68d) you were trying to merge in, and set MERGE_HEAD to it after you apply the stash.
Then you can apply the stash (with --index to re-stage everything that was staged before), and set your MERGE_HEAD
:
git stash apply --index
git update-ref MERGE_HEAD d7a9884a380f81b2fbf002442ee9c9eaf34ff68d