git stash blunder: git stash pop and ended up with merge conflicts

后端 未结 4 1799
滥情空心
滥情空心 2020-12-12 11:16

I did a git stash pop and ended up with merge conflicts. I removed the files from the file system and did a git checkout as shown below, but it thi

4条回答
  •  没有蜡笔的小新
    2020-12-12 11:22

    If, like me, what you usually want is to overwrite the contents of the working directory with that of the stashed files, and you still get a conflict, then what you want is to resolve the conflict using git checkout --theirs -- . from the root.

    After that, you can git reset to bring all the changes from the index to the working directory, since apparently in case of conflict the changes to non-conflicted files stay in the index.

    You may also want to run git stash drop [] afterwards, to get rid of the stash, because git stash pop doesn't delete it in case of conflicts.

提交回复
热议问题