Git:代碼衝突常看法決方法

出處:https://stackoverflow.com/questions/26659305/error-your-local-changes-to-the-following-files-would-be-overwritten-by-mergephp

 

 

若是系統中有一些配置文件在服務器上作了配置修改,而後後續開發又新添加一些配置項的時候,git

在發佈這個配置文件的時候,會發生代碼衝突:服務器

error: Your local changes to the following files would be overwritten by merge:
        protected/config/main.php
Please, commit your changes or stash them before you can merge.rest

若是但願保留生產服務器上所作的改動,僅僅併入新配置項, 處理方法以下:code

git stash
git pull
git stash pop

而後能夠使用git diff -w +文件名 來確認代碼自動合併的狀況.開發

 

反過來,若是但願用代碼庫中的文件徹底覆蓋本地工做版本. 方法以下:it

git reset --hard
git pull

其中git reset是針對版本,若是想針對文件回退本地修改,使用io

git checkout HEAD file/to/restore
相關文章
相關標籤/搜索