服务器上git pull是出现以下错误:1
2
3
4
5error: Your local changes to the following files would be overwritten by merge:
application/config/config.php
application/controllers/home.php
Please, commit your changes or stash them before you can merge.
Aborting
不知道什么原因造成的代码冲突,处理方法如下:
如果希望保留生产服务器上所做的改动,仅仅并入新配置项:1
2
3git stash
git pull
git stash pop
然后可以使用git diff -w +文件名 来确认代码自动合并的情况.
如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:1
2git reset --hard
git pull
其中git reset是针对版本,如果想针对文件回退本地修改,使用1
git checkout HEAD file/to/restore
在开发过程中,git提交的过程中合并了很多东西提交上去,就是这个原因,解决方法就是先放入暂存区,然后pull,再pop然后提交。
如果多次提交的话,先git reset到原来的状态,然后git pull拉下代码,再git add . & git commit代码,再git push。