方法一、
git pull 出現沖突后丟棄本地沖突文件,使用遠程文件覆蓋本地文件
git checkout [文件路徑]
git checkout test/src/main/resources/application.yml
git pull;
IDEA 可以試用revert
方法二、
git pull 出現沖突后可以暫存本地修改git stash save "savemessage"
,然后git pull
更新代碼,git stash list
可查看暫存記錄列表,釋放本地暫存 git stash apply stash@{0}
,出現沖突文件,找到並解決,然后可以提交git add .
加入索引庫,然后本地提交git commit -m
'注釋' 最后git push到遠程
方法三、
- 當執行git pull更新代碼時,發現以下錯誤
error: Your local changes to the following files would be overwritten by merge:application.yml
Please commit your changes or stash them before you merge.
這說明你的application.yml與遠程有沖突,你需要先提交本地的修改然后更新。
-
git add application.yml,然后使用 git commit -m '沖突解決',
提交本地的application.yml文件,不進行推送遠程
-
git pull,更新代碼會出現以下錯誤提示
Auto-merging application.yml CONFLICT (content): Merge conflict in application.yml Automatic merge failed; fix conflicts and then commit the result.
更新后你的本地分支上會出現 (develop|MERGING)類似這種標志
-
找到你本地的application.yml文件,並打開
你會在文件中發現<<<<<<< HEAD ,======= ,>>>>>>> ae9a0f6b7e42fda2ce9b13cfc5344d61
這種標記,<<<<<<< HEAD和=======中間的是你自己的代碼, ======= 和>>>>>>>中間的是其他人修改的代碼
自己確定保留那一部分代碼,最后刪除<<<<<<< HEAD ,======= ,>>>>>>>這種標志
-
重新使用git add application.yml,然后git commit -m '沖突解決結束',再次將本地的application.yml文件提交
-
解決沖突后,使用git push,將文件推送到遠程