问题描述
我在不同的地方对Makefile
进行了更改。
为什么我仍然出现错误?
$ git stash pop
error: Your local changes to the following files would be overwritten by merge:
Makefile
Please commit your changes or stash them before you merge.
Aborting
The stash entry is kept in case you need it again.
我的更改没有相交。因此,我希望它们可以毫无问题地合并。
解决方法
存在一些技术问题,这些问题阻止git stash pop
与其他命令一样自由使用索引(因为它实际上修改了索引本身),并且避免了stash apply
机制周围的复杂逻辑,此时,git stash pop
只是拒绝对“不干净的”文件应用更改。
解决此问题的简单方法是使用上述文件创建提交:
git add Makefile
git commit -m "wip"
git stash pop
# ... fix stuff if needed ...
# after stash application : you can jump one commit backwards
git reset --soft HEAD^ # if you want to keep stuff in the index
git reset HEAD^ # if you can reset the index too