Git stash pop- needs merge, unable to refresh index

后端 未结 10 1743
遥遥无期
遥遥无期 2020-12-12 20:00

I can\'t pop my stash because I merged a branch which apparently conflicts with my stash and now my stash is seemingly unable to be popped.

app.coffee: needs         


        
相关标签:
10条回答
  • 2020-12-12 20:43

    You need to add app.coffee to staging.

    Do git add app.coffee and then you will be able to apply your stash (after that commit and push).

    0 讨论(0)
  • 2020-12-12 20:44

    The stash has already been applied to other files.

    It is only app.coffee that you have to merge manually. Afterwards just run

    git reset

    to unstage the changes and keep on hacking.

    0 讨论(0)
  • 2020-12-12 20:45

    Its much simpler than the accepted answer. You need to:

    1. Check git status and unmerged paths under it. Fix the conflicts. You can skip this step if you'd rather do it later.

    2. Add all these files under unmerged paths to index using git add <filename>.

    3. Now do git stash pop. If you get any conflicts these will again need to be resolved.

    0 讨论(0)
  • 2020-12-12 20:46

    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.


    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.

    0 讨论(0)
提交回复
热议问题