解决error: Your local changes to the following files would be overwritten by merge
在项目里我们一般都会把自己第一次提交的配置文件忽略本地跟踪
|
1
|
[Sun@webserver2 demo]$ git update-index --assume-unchanged <filename> |
但是项目里的其他人如果不小心把该配置文件修改push到远程仓库之后,我们git pull代码的时候就会报错
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[Sun@webserver2 demo]$ git add .[Sun@webserver2 demo]$ git commit -m 'update:index.php'[master f8a7428] update:index.php 1 file changed, 1 insertion(+), 1 deletion(-)[Sun@webserver2 demo]$ git pullremote: Counting objects: 5, done.remote: Compressing objects: 100% (2/2), done.remote: Total 3 (delta 1), reused 0 (delta 0)Unpacking objects: 100% (3/3), done.From git.oschina.net:sunzmit/thinkphp 1bc9485..c63dff3 master -> origin/mastererror: Your local changes to the following files would be overwritten by merge: config.ini |
大意是:您的本地更改的文件将被合并覆盖。并指出了会被覆盖的文件
解决方法:
1.撤销本地对文件的忽略
|
1
|
[Sun@webserver2 demo]$ git update-index --no-assume-unchanged config.ini |
2.从最近的一次提交中读取内容,备份当前的工作区的内容,将当前的工作区内容保存到Git栈中
|
1
2
3
|
[Sun@webserver2 demo]$ git stashSaved working directory and index state WIP on master: f8a7428 update:index.phpHEAD is now at f8a7428 update:index.php |
3.pull远程仓库代码
|
1
2
3
4
|
[Sun@webserver2 demo]$ git pullMerge made by the 'recursive' strategy. config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) |
4.从Git栈中读取最近一次保存的内容,恢复工作区的相关内容
|
1
2
3
|
[Sun@webserver2 demo]$ git stash popAuto-merging config.iniCONFLICT (content): Merge conflict in config.ini |
5.修改合并
|
1
2
3
4
5
6
7
8
|
[Sun@webserver2 demo]$ vim config.ini<<<<<<< Updated upstreamThis is a test file!!!!!!!!!!!!!!!!=======This is a test file>>>>>>> Stashed changes[Sun@webserver2 demo]$ cat test.txtThis is a test file |
<<<<<<< Updated upstream到=======中是从远程仓库pull下来别人的内容,=======到>>>>>>> Stashed changes中是我们本地文件内容,现在我们可以删除其他,只保留自己的内容This is a test file
6.把文件回复到最新提交的版本,会保留修改内容
|
1
2
3
4
5
|
[Sun@webserver2 demo]$ git reset HEAD config.iniUnstaged changes after reset:M config.ini[Sun@webserver2 demo]$ cat test.txtThis is a test file |
7.再次忽略本地跟踪,完成!
|
1
|
[Sun@webserver2 demo]$ git update-index --assume-unchanged config.ini |
8.最后不要忘记清除Git栈的备份
|
1
|
[Sun@webserver2 demo]$ git stash drop |
本文永久地址:http://blog.it985.com/10665.html
本文出自 IT985博客 ,转载时请注明出处及相应链接。
解决error: Your local changes to the following files would be overwritten by merge的更多相关文章
- 解决 error: Your local changes to the following files would be overwritten by merge:XXXX
版权声明:这可是本菇凉辛辛苦苦原创的,转载请记得带上我家地址,不要忘记了哈 ... https://blog.csdn.net/u011314442/article/details/78852547 ...
- git error: Your local changes to the following files would be overwritten by merge:xxxxxx ,Please commit your changes or stash them before you merge.的phpstorm解决办法
git报错 error: Your local changes to the following files would be overwritten by merge: .idea/encoding ...
- Git版本控制工具使用:Error pulling origin: error: Your local changes to the following files would be overwritten by merge
摘自: CSDN 逆觞 git在pull时,出现这种错误的时候,可能很多人进进行stash,相关stash的请看:Error pulling origin: error: Your local cha ...
- Error pulling origin: error: Your local changes to the following files would be overwritten by merge
Git在pull时,出现这种错误的时候,可能很多人进进行stash,相关stash的请看:Error pulling origin: error: Your local changes to the ...
- Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.的问题解决(Git代码冲突)
在使用git pull拉取服务器最新版本时,如果出现error: Your local changes to the following files would be overwritten by m ...
- Laravel 5.2--git冲突error: Your local changes to the following files would be overwritten by merge:
今天在服务器上git pull是出现以下错误: error: Your local changes to the following files would be overwritten by mer ...
- git pull的时候发生冲突的解决方法之“error: Your local changes to the following files would be overwritten by merge”
今天在使用git pull 命令的时候发生了以下报错 目前git的报错提示已经相关友好了,可以直观的发现,这里可以通过commit的方式解决这个冲突问题,但还是想看看其他大佬是怎么解决这类问题的 在网 ...
- 在Linux上git pull线上仓库代码时,出现error: Your local changes to the following files would be overwritten by merge
在Windows上工作时未出现过该问题,于是通过命令: git diff 查看差异,得到结果: diff --git a/start_crons.sh b/start_crons.sh old mod ...
- Git pull error: Your local changes to the following files would be overwritten by merge:
联合开发,遇上的一个问题,果然,在此验证了百度的不靠谱,是谷歌出的答案...... stackoverflow上有解决方案,链接:http://stackoverflow.com/questions/ ...
随机推荐
- Hypothesis Testing
Hypothesis Testing What's Hypothesis Testing(假设检验) Hypothesis testing is the statistical assessment ...
- ie浏览器不兼容css媒体查询的解决办法
有些页面布局复杂,在不同分辨率下表现需要一致,这时需要用媒体查询根据不同分辨率进行百分比定位(不能用像素定位),如: @media screen and (max-width: 1600px) { . ...
- angular学习笔记(十七)-路由和切换视图
本篇介绍angular中如何通过判断url的hash值来显示不同的视图模板,并使用不同的控制器: 下面,通过一个例子,来一步一步说明它的用法: 我们要做一个邮箱应用,打开的时候显示的是邮件列表: 然后 ...
- 【Ubuntu】用户切换到root
出于安全考虑,默认时 Ubuntu 的 root 用户时没有固定密码的,它的密码是随机产生并且动态改变的,貌似是每5分钟改变一次,所以用 su(switch user) 是不可以的,因为我们不知道 r ...
- 四、用“”或构造函数创建Java的String区别
在Java中,一个字符串可以通过下面两种方法创建. String x = "abc"; String y = new String("abc"); 用双引号创建 ...
- nodejs字符串操作
nodejs的字符串操作需要引入querystring对象,querystring对象的方法有: 1:querystring.stringify(“对象”,“分隔符”,“分配符”),用来将一个json ...
- Query图像滑块插件 (支持触摸/滑动手势)
1.http://bxslider.com/ 2.http://www.slidesjs.com/ (http://www.html5cn.org/article-6437-1.html很多歌)
- Linux下安装Python3.6和第三方库
如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境, 比如yum!!!!! 不要动现有的python2环境! 一.安装p ...
- c# datetime与 timeStamp时间戳 互相转换
将时间格式转化为一个int类型 // ::26时间转完后为:1389675686数字 为什么使用时间戳? 关于Unix时间戳,大概是这个意思,从1970年0时0分0秒开始到现在的秒数.使用它来获得的是 ...
- LeetCode: Search for a Range 解题报告
Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given ...