前端开发

git使用webstorm更新代码,导致未提交代码被覆盖

2020-01-16  本文已影响0人  再见那卑微的再见

今天在准备提交代码时,先执行了webstorm的upadte功能,执行完之后发现所有新增和有改动的代码都消失了,直接被覆盖了。webstorm event log里提示:

Local changes were not restored
Before update your uncommitted changes were saved to stash.
Update is not complete, you have unresolved merges in your working tree
Resolve conflicts, complete update and restore changes manually.

大致意思是本地merge失败,本地的改动被保存到一个stash存档里
解决方案:
查看存档列表:git stash list
读最新存档:git stash pop
读指定存档:git stash apply stash@{存档编号}
如:git stash apply stash@{0}

但是读取存档时依旧报错,之后我再执行git add .,然后执行 git commit,最后再执行上述读取存档操作就成功了,被覆盖的代码也恢复了。

所以以后提交代码时一定要先commit,再push

上一篇 下一篇

猜你喜欢

热点阅读