How to abort a stash pop?

Question

I popped a stash and there was a merge conflict. Unlike the question that is listed as a duplicate, I already had some uncommitted changes in the directory which I wanted to keep. I don't just want to make the merge conflict disappear, but also to get my directory back to the state it was before the pop.

I tried git merge --abort, but git claimed no merge was in progress. Is there an easy way to abort a pop without destroying the changes I originally had in the directory?

Answer

Simple one liner

I have always used

git reset --merge

I can't remember it ever failing.


Note: git reset --merge will discard any staged changes. Also, as noted by @Saroopashree Kumaraguru in the comments, the stash contents won't be lost and can be re-applied later.

git ignore exception

How to undo "git commit --amend" done instead of "git commit"