解决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/ ...
随机推荐
- vim:查看当前的配置文件名称和地址
vim把当前使用的配置文件地址放置在变量MYVIMRC中.在vim使用echo查看即可: :echo $MYVIMRC
- LoadRunner Controller 常见用法
Controller 工作原理:通过场景设计来模拟用户的真实操作并调用vugen中的脚本,再通过设置的压力机产生压力 Scenario-convert scenario to the percenta ...
- ubuntu 清理系统垃圾与备份
虽然linux下不会有windows下的那么多垃圾和磁盘碎片!但还是会留下一些用不着的临时文件或是多次升级后的N个旧的内核! 1,非常有用的清理命令:sudo apt-get autocleansud ...
- Oracle PLSQL Demo - 09.Open、Fetch遍历游标[Open, Fetch, Close Record CURSOR]
declare r_emp scott.emp%rowtype; cursor cur_emp is select t.* from scott.emp t; begin open cur_emp; ...
- [转]好用工具:Oracle SQL Developer
我們一直以來就很少使用 Oracle 資料庫,一年下來也頂多 1 ~ 2 個案子採用 Oracle 的資料庫,所以一直都對 Oracle 資料庫的操作不太熟悉,尤其是用 Oracle 內建的那些超難用 ...
- ioss使用xcode常用快捷键
// command+r 运行 //command+.停止 // command+shift+y 弹出打印区 // command+z 回退 //command+shift+z 前进 // comma ...
- ThinkPHP框架快捷键使用说明
ThinkPHP框架快捷键使用说明 php mvc框架ThinkPHP中有很多快捷键,但是很多时候我们不太明白它的意思,下面我简单的列了下他们的含义: A快速实例化Action类库 B执行行为类 C配 ...
- Springmvc mvc:exclude-mapping不拦截 无效
最近在使用ssm框架搭建一个后台,需要判断每个请求都判断是否登录,未登录跳转到登录页面, 使用发现 mvc:exclude-mapping 不拦截,发现,怎么都无效,依然是进行拦截.查了很多资料,总算 ...
- dubbox2.8.4例子教程二
简介 上篇博客写了个dubbox生产者,也用HttpClient代码测试了rest服务,下面记录dubbox消费者工程 一.工程结构 一.Simple.java package bhz.ent ...
- window 服务(一)
windows服务应用程序是一种长期运行在操作系统后台的程序,它对于服务器环境特别适合,它没有用户界面,不会产生任何可视输出,任何用户输出都回被写进windows事件日志.计算机启动时,服务会自动开始 ...