在使用git pull拉取服務器最新版本時,如果出現error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.錯誤時,代表這代碼沖突了,本地修改了代碼導致無法覆蓋服務器上的。
此時有如下解決方法:
(注意:在做所有操作前,切記要先備份本地代碼。)
1、如果希望保留生產服務器上所做的改動,僅僅並入新配置項, 處理方法如下:
git stash
git pull
git stash pop
然后可以使用Git diff -w +文件名來確認代碼自動合並的情況。
2、如果要直接使用服務器上最新版本,那么可以選擇直接覆蓋
git reset --hard
git pull
其中git reset是針對版本。
以上參考:http://blog.csdn.net/iefreer/article/details/7679631