用git pull来更新代码的时候,遇到了下面的问题:

1
2
3
4
error: Your local changes to the following files would be overwritten by merge:
    xxx/xxx/xxx.php
Please, commit your changes or stash them before you can merge.
Aborting

出现这个问题的原因是其他人修改了xxx.php并提交到版本库中去了,而你本地也修改了xxx.php,这时候你进行git pull操作就好出现冲突了,解决方法,在上面的提示中也说的很明确了。

1、保留本地的修改 的改法

1)直接commit本地的修改 ----也一般不用这种方法

2)通过git stash  ---- 通常用这种方法

1
2
3
git stash
git pull
git stash pop

通过git stash将工作区恢复到上次提交的内容,同时备份本地所做的修改,之后就可以正常git pull了,git pull完成后,执行git stash pop将之前本地做的修改应用到当前工作区。

git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。

git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。

git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。

git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。

2、放弃本地修改 的改法  ----这种方法会丢弃本地修改的代码,而且不可找回

1
2
git reset --hard
git pull<br><br><br><br><br><br>

Git冲突:commit your changes or stash them before you can merge. 解决办法的更多相关文章

  1. (转)Git冲突:commit your changes or stash them before you can merge. 解决办法

    用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

  2. git pull和git merge区别&&Git冲突:commit your changes or stash them before you can merge. 解决办法

    http://blog.csdn.net/sidely/article/details/40143441 原文: http://www.tech126.com/git-fetch-pull/ Git中 ...

  3. Git更新本地仓库及冲突"Commit your changes or stash them before you can merge"解决

    Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin mastergit log  ...

  4. Git的commit your changes or stash them before you can merge

    今天用git pull来更新代码,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

  5. Git 解决方案 commit your changes or stash them before you can merge

    error: Your local changes to the following files would be overwritten by merge: *********** Please, ...

  6. Git冲突:commit your changes or stash them before you can merge.

    用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

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

  8. Git提交代码冲突:commit your changes or stash them before you can merge.

    用git pull拉取远程分支代码时候遇到如下问题: error: Your local changes to the following files would be overwritten by ...

  9. git pull冲突:commit your changes or stash them before you can merge.

    今天用git pull来更新代码,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

随机推荐

  1. Windows系统调用架构分析—也谈KiFastCallEntry函数地址的获取

    为什么要写这篇文章 1.      因为最近在学习<软件调试>这本书,看到书中的某个调试历程中讲了Windows的系统调用的实现机制,其中讲到了从Ring3跳转到Ring0之后直接进入了K ...

  2. setTimeOut一些注意的地方

    for (var i = 0; i < data.length; i++) { var flashID = data[i].ID; //setTimeOut(removeFlashDiv(fla ...

  3. 【PHP】 解决报错:Error: php71w-common conflicts with php-common-5.4.16-43.el7_4.x86_64

    背景: 手动安装的PHP7 环境 问题:在安装扩展的时候.无论输入 php-*  来安装任何扩展.都会报错 Error: php71w-common conflicts with php-common ...

  4. android 动画学习系列(一)

    老师今天开始讲android的游戏,讲到了view和surfaceview 下面是view的演示部分 private Paint paint; //游戏里很少用double,都是用long priva ...

  5. N小时改变一次url时间戳的方法

    //为url添加时间戳//time 为多长时间改变一次时间戳,以小时为单位function setTimeStamp(url, time){    var time = time || 4,      ...

  6. Windows Phone 7 检查手机网络

    using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Wi ...

  7. 310实验室OTL问题----将写好的C++文件转换成Python文件,并将数据可视化

    如图:文件夹 第一处:optimizer文件夹下的:optimizer.h文件中添加你所写代码的头文件  #include <OTL/Optimizer/Reference-NSGA-II/Re ...

  8. jquery插件方式实现table查询功能

    1.写插件部分,如下: ;(function($){ $.fn.plugin = function(options){ var defaults = { //各种属性,各种参数 } var optio ...

  9. poj1952 BUY LOW, BUY LOWER【线性DP】【输出方案数】

    BUY LOW, BUY LOWER Time Limit: 1000MS   Memory Limit: 30000K Total Submissions:11148   Accepted: 392 ...

  10. 对10进制16位长的主键的缩短处理 NULL

    # 对问题表去除旧有主键,新建自增主键:ALTER TABLE `question`CHANGE COLUMN `id` `id16` bigint(20) NULL COMMENT 'id_to_d ...