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

idea 上将本地代码推送到 git后 , 报错如下图

  1.  
    error: Your local changes to the following files would be overwritten by merge:
  2.  
    src/main/resources/application-prod.properties
  3.  
    Please, commit your changes or stash them before you can merge.

我和同事在改同一个接口,没有注意到他什么时候提交的,应该是忘记了先 pull 。

解决方法 1:

保留本地最新修改,并拉取仓库中忘记 pull 的代码到本地 :

三个命令:

  1.  
    git stash
  2.  
    git pull origin master
  3.  
    git stash pop

解决方法 2:

放弃本地代码,新修改的都不要了,退回上一版本,再拉取代码到本地。

  1.  
    git reset --hard
  2.  
    git pull origin master

PS : 如上图,我选择了方法1。后续操作一切正常。

后记(2018.6.13):又看到 另一种类似的操作

在使用Git的过程中,有些时候我们只想要 git 服务器中的最新版本的项目,对于本地的项目中修改不做任何理会,就需要用到 Git pull 的强制覆盖,具体命令如下:

  1.  
    git fetch --all
  2.  
    git reset --hard origin/master
  3.  
    git pull

Git pull的强制覆盖本地文件在自动化部署项目中很有作用,比如用 SaltStack 部署 web 项目,强制覆盖可以保持与服务器内容一致

解决 error: Your local changes to the following files would be overwritten by merge:XXXX的更多相关文章

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

    在项目里我们一般都会把自己第一次提交的配置文件忽略本地跟踪 1 [Sun@webserver2 demo]$ git update-index --assume-unchanged <filen ...

  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. ranch 源码分析(完)

    接上 ranch 源码分析(三) 在上一次,根据ranch源码把大概流程理了一遍,下面我们将一些细节解释一下. ranch只是一个服务的框架,它提供了传输层协议代码(ranch_tcp 和ranch_ ...

  2. 博弈论初步(SG函数)

    讲解见此博客https://blog.csdn.net/strangedbly/article/details/51137432 理解Nim博弈,基于Nim博弈理解SG函数的含义和作用. 学习求解SG ...

  3. Spring IOC、AOP、Transaction、MVC小结

    1.IOC.AOP:把对象交给Spring进行管理,通过面向切面编程来实现一些“模板式”的操作,使得程序员解放出来,可以更多的关注业务实现.                             - ...

  4. IntelliJ IDEA 注册码——亲测有效

    链接地址:http://idea.lanyus.com 使用时需要将“0.0.0.0 account.jetbrains.com”添加到hosts文件中,mac操作hosts文件可以参考链接: htt ...

  5. docker 安装redis , 让宿主机可以访问

    1, docker 拉去最新版本的redis docker pull redis #后面可以带上tag号, 默认拉取最新版本 2, docker安装redis container 安装之前去定义我们的 ...

  6. Oracle中 “ORA-14551: 无法在查询中执行 DML 操作” 如何解决

    在编写一个数据库函数时,方法实现需要查询后进行修改,出现ora-14551的错误 create or replace function fun_DxcBillSn(tabType integer,ta ...

  7. Rsync数据同步服务

    Rsync数据同步服务 Rsync软件适用与unix/linux/windows等多种操作系统平台 Rsync是一款开源的,快速的,多功能的,可实现全量及增量的本地或远程数据同步备份的优秀工具,可以实 ...

  8. mvc控制器

    控制器 using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.We ...

  9. 使用Python统计函数绘制复杂图形matplotlib

    一.堆积图 1.堆积柱状图 如果将函数bar()中的参数bottom的取值设定为列表y.列表y1代表另一个数,函数bar(x,y1,bottom=y,color="r")就会输出堆 ...

  10. FreeType使用的总结

    http://www.cppblog.com/liangairan/archive/2016/09/11/214270.html 这里说一下Freetype的关键点,比较基础的在很多文章已经有说明,这 ...