下班的時候準備提交(git)代碼走人 , 先更新到本地,然后再提交,這是平常一直使用的步驟。結果執行更新后,沒有提示合并,把代碼給我回退了到以前的版本了,在intellij 右下角提示了 Local changes were not restored
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.
image.png
- 意思是:代碼和服務器上的有沖突,合并失敗了。未提交的更改被暫時保存到了stash (git的暫存區),要手動處理合并。
1 . 命令操作
# 查看存檔列表,根據列表時間大概可以找出要恢復的東西
git stash list
# 使用指定存檔 , 存檔編號就是上個命令中看到類似`stash@{0}`
git stash apply stash@{存檔編號}
image.png
2 . Intellij 操作
image.png
image.png