在项目里我们一般都会把自己第一次提交的配置文件忽略本地跟踪

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 pull
remote: 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/master
error: 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 stash
Saved working directory and index state WIP on master: f8a7428 update:index.php
HEAD is now at f8a7428 update:index.php

3.pull远程仓库代码

1
2
3
4
[Sun@webserver2 demo]$ git pull
Merge 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 pop
Auto-merging config.ini
CONFLICT (content): Merge conflict in config.ini

5.修改合并

1
2
3
4
5
6
7
8
[Sun@webserver2 demo]$ vim config.ini
<<<<<<< Updated upstream
This is a test file!!!!!!!!!!!!!!!!
=======
This is a test file
>>>>>>> Stashed changes
[Sun@webserver2 demo]$ cat test.txt
This 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.ini
Unstaged changes after reset:
M config.ini
[Sun@webserver2 demo]$ cat test.txt
This 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的更多相关文章

  1. 解决 error: Your local changes to the following files would be overwritten by merge:XXXX

    版权声明:这可是本菇凉辛辛苦苦原创的,转载请记得带上我家地址,不要忘记了哈 ... https://blog.csdn.net/u011314442/article/details/78852547 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. git pull的时候发生冲突的解决方法之“error: Your local changes to the following files would be overwritten by merge”

    今天在使用git pull 命令的时候发生了以下报错 目前git的报错提示已经相关友好了,可以直观的发现,这里可以通过commit的方式解决这个冲突问题,但还是想看看其他大佬是怎么解决这类问题的 在网 ...

  8. 在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 ...

  9. Git pull error: Your local changes to the following files would be overwritten by merge:

    联合开发,遇上的一个问题,果然,在此验证了百度的不靠谱,是谷歌出的答案...... stackoverflow上有解决方案,链接:http://stackoverflow.com/questions/ ...

随机推荐

  1. Android学习之Android 5.0分享动画实现微信点击全屏效果

    Android5.0过渡动画,请看 http://blog.csdn.net/qq_16131393/article/details/51112772 今天用分享动画实现微信点击全屏效果 本文源代码下 ...

  2. 同一个界面内取微信的OPENID和调用微信的分享接口

    步骤如下,1:判断URL是否有CODE参数传入,没有则拼接那个微信跳转连接,然后redirect2:有CODE传入,调用微信接口,根据code获取openid和access_token,注意这一步取到 ...

  3. PYNQ = Python + ZYNQ —— ZYNQ部分功能的Python化

    PYNQ优点:1.    Python用于ZYNQ开发,Python库和FPGA硬件库可以直接调用,极大加快开发进程.缩短开发周期.降低开发难度,更方便.快捷:2.    用PYNQ开发,当Pytho ...

  4. webBench&ad网站并发测试工具

    webBench 测试工具使用,网站上线前压力测试工具. ad测试工具

  5. compiled inline cache

    http://cr.openjdk.java.net/~jrose/pres/200910-VMIL.pdf https://wiki.openjdk.java.net/display/HotSpot ...

  6. 关于Snmp的Trap代码开发之坑

    最近是被这个snmp的trap给坑了,其实回想起来主要是对这个不了解.特别是对snmp协议研究不够深入, 真的不想看这些协议东西,只想大概知道.结果在开发snmp trap时候被坑了,下面列下自己踩到 ...

  7. 一些有用的Sql语句

    1.插入数据后,返回插入的Id ')

  8. eclipse tomcat timeout时间设置

    eclipse tomcat默认启动timeout时间太短,导致项目启动时间一长,就报错 如下设置: 工作空间\.metadata\.plugins\servers.xml文件 <?xml ve ...

  9. [应用]Linux下" >/dev/null 2>&1 "

    转自:http://blog.csdn.net/sunrier/article/details/7695839 这条命令的意思就是在后台执行这个程序,并将错误输出2重定向到标准输出1,然后将标准输出1 ...

  10. jffs2根文件系统制作

    http://www.eetop.cn/blog/html/98/510998-20964.html 作者:刘洪涛,华清远见嵌入式学院高级讲师,ARM公司授权ATC讲师. JFFS2是Flash上应用 ...