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. Linux命令(三)远程登录

  2. 20155216 2016-2017-2 《Java程序设计》第八周学习总结

    20155216 2016-2017-2 <Java程序设计>第八周学习总结 教材学习内容总结 认识NIO Java NIO 由以下几个核心部分组成: Channels Buffers S ...

  3. the error about “no such file or directory”

    CHENYILONG Blog the error about "no such file or directory" when you get the question like ...

  4. mysql开启远程连接及本地连接

    问题描述 在本机windows上连接linux服务器上的mysql报错:host'XXX' is not allowed to connect to this mysql server. 这个错误是由 ...

  5. python技巧 合并两个字典

    python 3.5+ 版本 In [1]: a={'x':2,'y':4} In [2]: b={'c':1,'d':3} In [3]: c={'c':3,'y':6} In [4]:  w={* ...

  6. 第12月第1天 MASConstraintMaker crash

    1. crash [valueLabel mas_makeConstraints:^(PAKitMASConstraintMaker *make) { make.left.equalTo(finish ...

  7. ViewGroup.layout(int l, int t, int r, int b)四个输入参数的含义

    ViewGroup.layout(int l, int t, int r, int b)这个方法是确定View的大小和位置的,然后将其绘制出来,里面的四个参数分别是View的四个点的坐标,他的坐标不是 ...

  8. tensorboard遇到的坑

    <ul><li>No graph definition files were found.</li></ul> <p>启动命令 tensor ...

  9. rap 部署

    Rap 安装 war包下载地址 https://github.com/thx/RAP/releases 创建数据库,并创建权限用户 mysql> create database rap_db c ...

  10. Java环境的搭建及用记事本来揭露下JDK到底做了些什么

    和我一样的新手想学Java就从自己搭建环境开始,请看完这边文章,我搜集资料的整合. Java的标准版本是Java SE,所说的JDK(Java Development Kits)就是Java SE的开 ...