Git pull时报错:commit your changes or stash them before you can merge. 的解决办法

今天在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文件并且其他人已经提交到了远程仓库,出现了冲突。

解决的办法有三种:

第一种:直接取消本地的修改--这种方式会丢弃现在的修改,而且不可找回(不推荐)

1、git reset --hard       --执行此命令需要本地修改的内容没有git add、git commit 。执行之后,git会回退到最近一次pull的状态。

2、git pull                    --拉取远程仓库文件

第二种:直接commit本地的修改--commit之后再执行pull命令,手动解决冲突,然后再提交到远程库(不推荐)

第三种:通过git stash命令

git stash   备份本地所做的修改,同时将工作区恢复到上次提交的内容。

git pull XXXX 操作完之后就可以正常的pull了

git stash pop  将之前本地做的修改应用到当前工作区。

Git pull时报错:commit your changes or stash them before you can merge. 的解决办法相关推荐

  1. git pull时提示错误:warning: ignoring broken ref refs/remotes/origin/HEAD的解决办法

    git pull时提示错误:warning: ignoring broken ref refs/remotes/origin/HEAD的解决办法 我用的是IDEA开发的GIT项目,首先找到你项目的根目 ...

  2. Laravel5.5执行 npm run dev时报错,提示cross-env找不到(not found)的解决办法

    Laravel 5.4 Mix & Laravel5.5执行 npm run dev时报错,提示cross-env找不到(not found)的解决办法 首先进入package.json文件, ...

  3. java HelloWorld时报错:“找不到或无法加载主类“问题的解决办法

    java HelloWorld时报错:"找不到或无法加载主类"问题的解决办法 参考文章: (1)java HelloWorld时报错:"找不到或无法加载主类"问 ...

  4. git第一次提交代码到码云,git pull 报错:fatal: refusing to merge unrelated histories

    第一次提交的步骤: 1.进入项目目录,执行 git init 2.连接远程仓库 git remote add origin 远程仓库地址(从码云乎哟这github上复制地址即可) 3.报错:git p ...

  5. git pull报错Pulling is not possible because you have unmerged files

    git pull 报错 error: Pulling is not possible because you have unmerged files. 解决办法 1. git add -u 2. gi ...

  6. git pull 报错 error: cannot pull with rebase: Your index contains uncommitted changes.

    git pull 报错 error: cannot pull with rebase: Your index contains uncommitted changes. error: please c ...

  7. 2021-08-03 git pull 报错 cannot lock ref

    git pull 报错:error: cannot lock ref 'refs/remotes/origin/release/xxx': 'refs/remotes/origin/release' ...

  8. git clone时报错 Empty reply from server

    使用git clone 时报错: wujc@wujc-VirtualBox:~/Desktop/rk3288$ sudo git clone https://github.com/FireflyTea ...

  9. git pull报错unexpected disconnect while reading sideband packet

    git pull报错unexpected disconnect while reading sideband packet 解决方法 修改http请求最大容量:git config http.post ...

最新文章

  1. Fine-tune之后的NLP新范式:Prompt越来越火,CMU华人博士后出了篇综述文章
  2. php 位深度,javascript - 流程图获取深度,求各位算法高手帮帮忙
  3. Tableau必知必会之图表显示部分标签的小妙招
  4. 宋体字体是什么_Win10 系统替换 macOS 苹方字体 - 瞬间提升文字清晰
  5. Leetcode题库 744.寻找比目标字母大的最小字母(C实现)
  6. java派生类_我可以使派生类从Java的基类继承派生成员...
  7. SpringBoot+Redis+Cookies实现高并发的购物车
  8. 数据库查询的table结果转成对应实体类
  9. UGUI实现摇杆(模仿太极熊猫)
  10. STM 事务 ACID
  11. 超酷的jQuery百叶窗图片滑块实现教程
  12. mysql后台数据库学习报告
  13. 计算机有残留office,电脑残留Office无法重装?电脑完全卸载Office方法
  14. Spring Cloud GateWay-过滤器
  15. 判断任意时刻、位置是白昼?黑夜?
  16. 关于智能机器人的一些伦理道德问题
  17. Android开机自启自动轮播图片或自动轮播视频APP
  18. pthread-win32库编译及使用方法注意事项
  19. Rosalind第七题:孟德尔第一定律
  20. JDK8的下载安装以及配置环境变量步骤

热门文章

  1. bigbang0106
  2. shardingsphere搭建使用,以及报错解决(一)
  3. 左耳听风-开篇词 :洞悉技术的本质,享受科技的乐趣
  4. DTK Barcode Reader SDK,支持各种文档和图像格式
  5. 渗透测试技术----提权(第三方提权和WCE)
  6. Netty---论内存池源设计的巧妙
  7. Materials Studio软件启动问题:Failed to initialise from settings. xml cleanly
  8. C# 232串口转485网络读卡器源码
  9. VMware设置虚拟机的网络为桥接模式,虚拟机使用主机的网段,虚拟机设置和主机一样的网关(网段)
  10. 《基于Node.js实现简易聊天室系列之详细设计》