解决error: Your local changes to the following files would be overwritten by merge
来源:互联网 发布:淘宝him折扣店是真的吗 编辑:程序博客网 时间:2024/05/30 04:39
在项目里我们一般都会把自己第一次提交的配置文件忽略本地跟踪
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博客 ,转载时请注明出处及相应链接。
0 0
- 解决error: Your local changes to the following files would be overwritten by merge
- Error pulling origin: error: Your local changes to the following files would be overwritten by merge
- Error pulling origin: 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 merge解决方法
- Git pull error: Your local changes to the following files would be overwritten by merge:
- git使用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:
- error: Your local changes to the following files would be overwritten by merge
- [Git] error: Your local changes to the following files would be overwritten by merge
- [Git] error: Your local changes to the following files would be overwritten by merge
- brew update 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:
- error Your local changes to the following files would be overwritten by merge
- git提示 error: Your local changes to the following files would be overwritten by merge:
- Your local changes to the following files would be overwritten by merge
- Your local changes to the following files would be overwritten by merge: git
- git pull 时出现 error: Your local changes to the following files would be overwritten by merge的解决办法
- git 提交后“Error: Your local changes to the following files would be overwritten by merge”解决办法
- 使用GitHub和Eclipse进行javaEE开发步骤
- MyEclipse安装EGit插件方法
- server library[unbound] 服务未绑定解决办法
- Shimeji开源桌宠代码学习(1)
- Spring-JDBC配置
- 解决error: Your local changes to the following files would be overwritten by merge
- 计算机概述,键盘快捷键,常见的DOS命令,Java语言概述,JDK、JRE、JVM之间的关系,环境变量的配置
- Tomcat的性能优化及部署时的参数调整
- Spring配置文件加载流程
- Unsupported major.minor version 51.0解决办法
- SPOJ_PT07Z 树最长路径问题
- Spring classPath:用法
- node.js实现文件读取\写入\复制内容——李帅醒博客
- Oracle查询优化--单表查询