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
相关文章
相关标签/搜索