问题描述

error: Your local changes to the following files would be overwritten by merge:
xxx/xxx/xxx.c
Please commit your changes or stash them before you can merge.
Aborting

问题分析

原因是 其他人/或你自己 修改了xxx.c并提交(git add .)到版本库中去了,你本地又想再提交xxx.c,
这时候你进行git pull操作就好出现冲突了,解决方法,在上面的提示中也说的很明确了。进行git commit或者git stash操作。

解决办法

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

  1)直接git commit本地的修改 ——一般不推荐这种方法,因为可能你还想修改该文件

  2)通过git stash——通常使用该方法

git stash
git pull
git stash pop

步骤解析:

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

git pull 或者 git pull <remote>  <branch>:拉取代码

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

此外还有:

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

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

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

git reset --hard
git pull

Over....

Please commit your changes or stash them before you merge问题解决的更多相关文章

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

  2. 【git冲突解决】: Please commit your changes or stash them before you merge.

    刚刚使用 git pull 命令拉取代码时候,遇到了这样的问题: error: Your local changes to the following files would be overwritt ...

  3. commit your changes or stash them before you can merge

    今天用git pull来更新代码,遇到了下面的问题: 今天git pull 出现以下问题 Please commit your changes or stash them before you mer ...

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

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

  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. Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge

    Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, com ...

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

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

随机推荐

  1. SAP内表类型及其数据读取效率评估

    内表大概分3种: 1.标准表standard tables:如果不指定BINARY SEARCH附加选项,则默认为线性查找(linear search),既一条一条的查找. 2.排序表(sorted ...

  2. ABAP program lines are wider than the internal table

    错误详细描述: An exception occurred that is explained in detail below.The exception, which is assigned to ...

  3. Flask扩展点总结(信号)

    信号(源码) 信号,是在flask框架中为我们预留的钩子,让我们可以进行一些自定义操作. pip3 install blinker 根据flask项目的请求流程来进行设置扩展点 1.中间件 from ...

  4. Mybatis【15】-- Mybatis一对一多表关联查询

    注:代码已托管在GitHub上,地址是:https://github.com/Damaer/Mybatis-Learning ,项目是mybatis-11-one2one,需要自取,需要配置maven ...

  5. pytest fixtures装饰器的使用

    一.pytest中可以使用@pytest.fixture 装饰器来装饰一个方法,被装饰方法的方法名可以作为一个参数传入到测试方法中.可以使用这种方式来完成测试之前的初始化,也可以返回数据给测试函数. ...

  6. kvm虚拟机管理(创建、连接)

    创建虚机.远程管理kvm虚机.virsh命令行下管理虚机..kvm通过virsh console 连入虚拟机   一.创建虚机 1)打开虚拟化管理器

  7. Python+Selenium+Unittest实现PO模式web自动化框架(3)

    1.Outputs目录下的具体目录功能 2.logs目录 logs目录是用于存放log日志的一个目录. 2.reports目录 reports目录是用于存放测试报告的. 3.screenshots目录 ...

  8. (Oracle)导出表结构

    DECLARE cursor t_name is SELECT rank() over(order by a.TABLE_NAME) as xiaolonglong,a.TABLE_NAME FROM ...

  9. apache httpclient 4 范例

    下面是一个通过apache httpclient 4 实现http/https的普通访问和BasicAuth认证访问的例子.依赖的第三方库为: 下面是具体实现: package test; impor ...

  10. LOJ10078

    CQOI 2005 重庆城里有 n 个车站,m 条双向公路连接其中的某些车站.每两个车站最多用一条公路连接,从任何一个车站出发都可以经过一条或者多条公路到达其他车站,但不同的路径需要花费的时间可能不同 ...