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

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

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、放弃本地修改 的改法

git reset --hard
git pull

转载请注明:知识蚂蚁 » Git冲突:commit your changes or stash them before you can merge. 解决办法

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

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

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

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

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

  4. Git冲突:commit your changes or stash them before you can merge. 解决办法

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

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

  7. (转)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 ...

  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. Arch 安装后,一些基本设置(1)

    1.安装成功后新建普通用户不能使用useradd进行一步添加,应该下载adduser交互式添加新用户,否则用户无法登陆. 2.安装openkeeper之前需要安装ppp和net-tools (需要里面 ...

  2. strlen函数,strcat函数,strcpy函数,strncpy函数,strcmp函数

    strcpy函数: char *strcpy(char *Dest , const char *Src) { assert((Dest != NULL) && (Src != NULL ...

  3. Gym 101617J Treasure Map(bfs暴力)

    http://codeforces.com/gym/101617/attachments 题意:给出一个图,每个顶点代表一个金矿,每个金矿有g和d两个值,g代表金矿初始的金子量,d是该金矿每天的金子量 ...

  4. transient关键字详解

    作用 1,一旦变量被transient修饰,变量将不再是对象持久化的一部分,该变量内容在序列化后无法获得访问. 2,transient关键字只能修饰变量,而不能修饰方法和类.注意,本地变量是不能被tr ...

  5. Antd-Select组件的深入用法

    一.Antd-Select提供几种类型 最基础版只提供下拉功能的选择器 带搜索功能的下拉选择器 可多选的下拉选择器 可搜索.可多选.可随意输入内容的tag下拉选择器(支持自动分词) 多级联动下拉选择器 ...

  6. 同上两篇 这篇是关于shader的

    资源加载性能测试代码 与上篇所提出的测试代码一样,我们对于Shader资源的加载性能分析同样使用该测试代码.同时,我们将Shader文件制作成一定大小的AssetBundle文件,并逐一通过以下代码在 ...

  7. Codeforces Round #200 (Div. 1) D. Water Tree 树链剖分+线段树

    D. Water Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard input ...

  8. activity 运行流程

    图1 图2 图3 图四

  9. CentOS6.X、7.X下Jenkins的安装及使用

    一.相关概念 1.1 Jenkins概念: Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Jenk ...

  10. 1. dubbo概述

    dubbo简介: 官网:http://dubbo.io 最大程度进行解耦,降低系统耦合性,可以跨工程,跨项目; 生产者/消费者模式; jdk:1.6以上 maven:3.0以上 国际maven仓库:h ...