Git:代码冲突常见解决方法
2015-07-22 14:27
253 查看
如果系统中有一些配置文件在服务器上做了配置修改,然后后续开发又新添加一些配置项的时候,
在发布这个配置文件的时候,会发生代码冲突:
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.
如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:
然后可以使用git diff -w +文件名 来确认代码自动合并的情况.
反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
其中git reset是针对版本,如果想针对文件回退本地修改,使用
[plain] view
plaincopy
git checkout HEAD file/to/restore
by iefreer
在发布这个配置文件的时候,会发生代码冲突:
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.
如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:
git stash git pull git stash pop
然后可以使用git diff -w +文件名 来确认代码自动合并的情况.
反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
git reset --hard git pull
其中git reset是针对版本,如果想针对文件回退本地修改,使用
[plain] view
plaincopy
git checkout HEAD file/to/restore
by iefreer
相关文章推荐
- Python串口编程
- eclipse使用maven插件打包JAR包
- javaWeb最全的文件上传下载
- Java开发环境配置方法
- Ruby 中的inject方法
- struts-tags在哪个包下
- OpenCV 实践程序17——用C++实现ip camera的视频播放
- hihoCoder 字符消除
- QTP场景恢复-Function Call
- matlab中repmat函数的用法
- “100 Best GitHub: Deep Learning”
- git向gitHub上push和pull数据.
- 【Java】有个排序后的字符串数组,其中散布着一些空字符串,编写一个方法,找出给定字符串的位置
- c语言,连接2个数组的方法???
- 伸展树 之 Java的实现
- PHP中获取当前页面的完整URL
- Python操作文件、文件夹、字符串
- C语言:将输入的字符串(char* cp)存入字符指针数组(char * spa[])
- php的时间格式总结(转)
- C语言变长数组data[0]【总结】