git报错:Auto Merge Failed; Fix Conflicts and Then Commit
本文来源:http://blog.csdn.net/trochiluses/article/details/10100719
1.出错场景:
协同开发时,我们从远程服务器上pull下代码的时候,出现以下提示信息:
Auto Merge Failed; Fix Conflicts and Then Commit the Result.
2.原因分析:
利用git status,输出如下:
root@hyk-virt:/etc# git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 2 different commits each, respectively.
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: apt/sources.list
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: cups/subscriptions.conf
# modified: cups/subscriptions.conf.O
# modified: mtab
# modified: update-manager/release-upgrades
#
no changes added to commit (use "git add" and/or "git commit -a")
从git status的结果可以发现:其中sources.list这个文件存在合并冲突
而进一步分析git pull的原理,实际上git pull是分了两步走的,(1)从远程pull下origin/master分支(2)将远程的origin/master分支与本地master分支进行合并
以上的错误,是出在了第二步骤
3.解决方法
方法一:如果我们确定远程的分支正好是我们需要的,而本地的分支上的修改比较陈旧或者不正确,那么可以直接丢弃本地分支内容,运行如下命令(看需要决定是否需要运行git fetch取得远程分支):
$:git reset --hard origin/master
或者$:git reset --hard ORIG_HEAD
解释:
git-reset - Reset current HEAD to the specified state
--hard
Resets the index and working tree. Any changes to tracked files
in the working tree since <commit> are discarded.
方法二:我们不能丢弃本地修改,因为其中的某些内容的确是我们需要的,此时需要对unmerged的文件进行手动修改,删掉其中冲突的部分,然后运行如下命令
$:git add filename
$:git commit -m "message"
方法三:如果我们觉得合并以后的文件内容比价混乱,想要废弃这次合并,回到合并之前的状态,那么可以运行如下命令:
$:git reset --hard HEAD
git报错:Auto Merge Failed; Fix Conflicts and Then Commit的更多相关文章
- Git使用出现Automatic merge failed; fix conflicts and then commit the result.解决方法
产生原因 首先这个问题产生的原因是因为你git pull 的时候会分为两步,第一步先从远程服务器上拉下代码,第二步进行merge,但是merge时候失败了就会产生上述问题. 解决方法: 丢弃本地提交, ...
- Automatic merge failed; fix conflicts and then commit the result.解决方法
产生原因: git pull 的时候会分为两步,第一步先从远程服务器上拉下代码,第二步进行merge.当你merge时候失败了就会产生Automatic merge failed; fix confl ...
- git 报错:error: failed to push some refs to 'https://github.com/Anderson-An/******.git'(已解决)
提交push 报错: $ git push origin masterTo https://github.com/Anderson-An/******.git ! [rejected] master ...
- git报错error: RPC failed; HTTP 500 curl 22 The requested URL returned error: 500
报错 $ git push; Enumerating objects: 1002, done. Counting objects: 100% (1002/1002), done. Delta comp ...
- 记Git报错-refusing to merge unrelated histories
记Git报错-refusing to merge unrelated histories 系统:win7 git版本: 2.16.2.windows.1 问题 1.本地初始化了git仓库,放了一些 ...
- Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). Git fet ...
- 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). 2017年02 ...
- Git客户端执行命令报错: fatal: Authentication failed for'xxxxx.git',但是又不弹出窗口重新输入用户名和密码的解决办法
1.Git版本:Git-2.17.0 2.引起git报错的原因 在变更远程仓库路径的的时候,弹出过一个窗口输入用户名和密码,但是输错了,之后执行任何拉取和更新的命令都会报如下的错: fatal: Au ...
- git:Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). 解决办法一:保 ...
随机推荐
- Java程序设计(2021春)——第四章接口与多态课后题(选择题+编程题)答案与详解
Java程序设计(2021春)--第四章接口与多态课后题(选择题+编程题)答案与详解 目录 Java程序设计(2021春)--第四章接口与多态课后题(选择题+编程题)答案与详解 第四章选择题 4.0 ...
- 使用POI把查询到的数据表数据导出到Excel中,一个表一个sheet.最详细!!!
一.需求 我们会遇到开发任务: 经理:小王,你来做一下把数据库里的数据导出到Excel中,一个表是一个sheet,不要一个表一个Excel. 小王:好的,经理.(内心一脸懵逼) 二.前期准备 首先我们 ...
- NOIP 模拟 $14\; \text{影魔}$
题解 \(by\;\;zj\varphi\) 不是原题 一道(对我来说)很需要技巧的题 对于颜色数如何处理 离线,将子树转化为 \(dfs\) 序,但这种做法无法处理深度 我们按照深度加点(可以通过 ...
- VMware上安装的Ubuntu不显示全屏解决方法
花费了好一会才把电脑上的Vmware装上,把Ubuntu装到虚拟机上,谁知道Ubuntu不显示全屏,我调了分辨率,奈何Ubuntu里面固定的分辨率没有跟我电脑匹配的,然后开始寻找解决方法,在网上找了很 ...
- Docker搭建网页数据库管理-Adminer
为什么Adminer比phpMyAdmin更好? 官网介绍: 用Adminer替换phpMyAdmin,您将获得一个简洁的用户界面,对MySQL功能的更好支持,更高的性能和更高的安全性.请参阅详细比较 ...
- reduce使用技巧
一.使用reduce同时执行map(循环)和filter(过滤) 例如,将数组中的项的值加倍,然后只选择那些大于50的项 const numbers = [10, 20, 30, 40]; const ...
- git 拉取代码指定分支
问题背景: 新项目还在开发阶段,没有正式对外发布,所以开发同事合并代码到develop上(或者其他名称分支上),而不是到master分支上 通过git拉取代码的时候,默认拉取的是master分支,如下 ...
- springmvc学习日志三
一.文件的上传 1.首先在lib中添加相应的jar包 2.建立jsp页面,表单必须是post提交,编码必须是multipart/form-data,文件上传文本框必须起名 <body> & ...
- MySQL时间戳、字符串、日期
1.时间转字符串:date_format(date, format) SELECT date_format(now(), '%Y-%m-%d') 2.时间转时间戳:unix_timestamp() S ...
- JAVA中直接用Jdbc就能操作数据库了,为什么还要用spring框架?
不过随着业务的扩展,你就会发现jdbc建立一个连接居然要几百毫秒,而执行一个普通的SQL仅仅需要几毫秒. 这么重量级的资源建立了就释放了不合适,得找个容器存起来,谁要就来取,不用了就还给容器,毕竟容器 ...