Git stash pop- needs merge, unable to refresh index
Here's how I solved the issue:
- git status (see a mix of files from a previous stash, pull, stash pop, and continued work.)
- git stash (see the needs merge issue)
- git add . (add the files so my work locally resolves my own merged)
- git stash (no error)
- git pull (no error)
- git stash pop (no error and continue working)
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.
Actually, just git add -- your file
, or (if you don't want those changes) git reset -- yourfile
(to unstage it) is enough to get past the error message.
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.