`git stash` during a merge conflict

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)