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 merge: ... Please, commit your changes or stash them before you can merge.错误时,代表这代码冲突了,本地修改了代码导致无法覆盖服务器上的。

此时有如下解决方法:

注意:在做所有操作前,切记要先备份本地代码。

1、如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:

git stash
git pull
git stash pop

然后可以使用Git diff -w +文件名来确认代码自动合并的情况。

2、如果要直接使用服务器上最新版本,那么可以选择直接覆盖

git reset --hard
git pull

其中git reset是针对版本。

http://blog.csdn.net/misakaqunianxiatian/article/details/51103734

##############################

方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)

git stash
git pull origin master
git stash pop

如此一来,服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了。

方法2、如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull

git reset --hard
git pull origin master

Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge的更多相关文章

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

  2. error: Your local changes to the following files would be overwritten by checkout:

    在发布这个配置文件的时候,会发生代码冲突: error: Your local changes to the following files would be overwritten by merge ...

  3. "Your local changes to the following files would be overwritten by merge" on git

    运行: git merge --ff origin/master 得到错误信息: error: Your local changes to the following files would be o ...

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

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

  6. 解决git pull出现: 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. 解决 error: Your local changes to the following files would be overwritten by merge:XXXX

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

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

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

随机推荐

  1. Spark记录-Scala集合

    Scala列表 Scala列表与数组非常相似,列表的所有元素都具有相同的类型,但有两个重要的区别. 首先,列表是不可变的,列表的元素不能通过赋值来更改. 其次,列表表示一个链表,而数组是平的. 具有类 ...

  2. bzoj千题计划254:bzoj2286: [Sdoi2011]消耗战

    http://www.lydsy.com/JudgeOnline/problem.php?id=2286 虚树上树形DP #include<cmath> #include<cstdi ...

  3. MySQL异步复制延迟解决

    http://www.ttlsa.com/mysql/mysql-5-7-enhanced-multi-thread-salve/

  4. google浏览器测试时清理缓存、强制不用缓存刷新快捷键(常用、效率)

    Ctrl+Shift+Del  清除Google浏览器缓存的快捷键  Ctrl+Shift+R  重新加载当前网页而不使用缓存内容

  5. CSS marging相关

    一.margin可以为负值 在盒模型中,内容区的width/height.padding.border都不能为负值,但是margin例外,它可以为负值. margin负值的本质,在于它改变了元素在普通 ...

  6. C++产生固定范围内的固定数量的随机数

    #include<iostream> #include<ctime> #include<random> using namespace std; void knut ...

  7. centos7下安装配置redis3.0.4

    安装redis 1.进入redis官网(redis.io)下载redis稳定版安装包,目前稳定版本为3.0.4 2.在linux  /usr文件夹下新建redis文件夹,拷贝安装包redis-3.0. ...

  8. 关于sklearn,监督学习几种模型的对比

    # K近邻,适用于小型数据集,是很好的基准模型,容易解释 from sklearn.neighbors import KNeighborsClassifier # 线性模型,非常可靠的首选算法,适用于 ...

  9. 【前端vue开发】vue开发输入姓名,电话,公司表单提交组件

    <template> <div id="parti-info"> <div> <span>您的姓名:</span> &l ...

  10. google地图的url参数

    Google Maps Intents for Android The Google Maps app for Android exposes several intents that you can ...