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

今天在准备提交代码时,先执行了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


本文章由javascript技术分享原创和收集

发表评论 (审核通过后显示评论):