问题描述

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. 06--Docker自定义镜像Tomcat9

    1. 创建目录 /zhengcj/mydockerfile/tomcat9 2.将jdk和tomcat的安装包拷贝到tomcat9下 3.在tomcat9目录下创建Dockerfile文件,并写以下命 ...

  2. LeetCode-P53题解【动态规划】

    本文为原创,转载请注明:http://www.cnblogs.com/kylewilson/ 题目出处: https://leetcode.com/problems/maximum-subarray/ ...

  3. [Usaco2006 Nov]Corn Fields牧场的安排

    题目描述 Farmer John新买了一块长方形的牧场,这块牧场被划分成M列N行(1<=M<=12; 1<=N<=12),每一格都是一块正方形的土地.FJ打算在牧场上的某几格土 ...

  4. celery 原理

    https://mp.weixin.qq.com/s/FzvZHQpF5mhV9t_HBzlcwg Celery 是一个 基于python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处 ...

  5. TypeScript基本类型

    类型注解 作用:相当于强类型语言中的类型声明 语法:(变量/函数):type 数据类型 新建src/datatype.ts,里面定义各种类型的数据 原始类型: let bool: boolean = ...

  6. 【LinxuShell】tar命令的用法

  7. 大白话入门 Spring Cloud

    首先我给大家看一张图,如果大家对这张图有些地方不太理解的话,我希望你们看完我这篇文章会恍然大悟. 什么是Spring cloud 构建分布式系统不需要复杂和容易出错.Spring Cloud 为最常见 ...

  8. socket更多方法

    一.socket的更多方法介绍 ###socket更多方法服务端套接字函数 s.bind() 绑定(主机,端口号)到套接字 s.listen() 开始TCP监听 s.accept() 被动接受TCP客 ...

  9. Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法

    原因分析: 这些代码因为是工具自动生成的,所以也没仔细检查.一个小小的错误,导致的. 解决办法: 1.由于使用ibatis的TempTestTableMapper.xml实现接口TempTestTab ...

  10. Postman 的 Post 请求方式的四种类型的数据

    Postman 的 Post 请求方式的四种类型的数据 1. form-data 2. x-www-form-urlencoded 3. raw 4. binary 1. form-data 就是 H ...