The stash entry is kept in case you need it again. There's no magic remedy for such merge conflicts. The only option for developers is to edit the file by hand and keep what they want and dispose of what they don't want. Once they merge and save the file, they will have effectively resolved the git stash conflict.
To pop Git stashes, simply use the “git stash pop” command and specify the stash index you want to pop.
First, check git status
.
As the OP mentions,
The actual issue was an unresolved merge conflict from the merge, NOT that the stash would cause a merge conflict.
That is where git status
would mention that file as being "both modified
"
Resolution: Commit the conflicted file.
Solution: in this case, simply add and commit your local file.
You can find a similar situation 4 days ago at the time of writing this answer (March 13th, 2012) with this post: "‘Pull is not possible because you have unmerged files’":
julita@yulys:~/GNOME/baobab/help/C$ git stash pop
help/C/scan-remote.page: needs merge
unable to refresh index
What you did was to fix the merge conflict (editing the right file, and committing it):
See "How do I fix merge conflicts in Git?"
What the blog post's author did was:
julita@yulys:~/GNOME/baobab/help/C$ git reset --hard origin/mallard-documentation
HEAD is now at ff2e1e2 Add more steps for optional information for scanning.
I.e aborting the current merge completely, allowing the git stash pop
to be applied.
See "Aborting a merge in Git".
Those are your two options.
Here's how I solved the issue:
I was having this issue, then resolving the conflict and commiting, and doing git stash pop
again was restoring the same stash again (causing the same conflict :-( ).
What I had to do (WARNING: back up your stash first) is git stash drop
to get rid of it.
Its much simpler than the accepted answer. You need to:
Check git status
and unmerged paths under it. Fix the conflicts. You can skip this step if you'd rather do it later.
Add all these files under unmerged paths to index using git add <filename>
.
Now do git stash pop
. If you get any conflicts these will again need to be resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With