本文来源: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的更多相关文章

  1. Git使用出现Automatic merge failed; fix conflicts and then commit the result.解决方法

    产生原因 首先这个问题产生的原因是因为你git pull 的时候会分为两步,第一步先从远程服务器上拉下代码,第二步进行merge,但是merge时候失败了就会产生上述问题. 解决方法: 丢弃本地提交, ...

  2. Automatic merge failed; fix conflicts and then commit the result.解决方法

    产生原因: git pull 的时候会分为两步,第一步先从远程服务器上拉下代码,第二步进行merge.当你merge时候失败了就会产生Automatic merge failed; fix confl ...

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

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

  5. 记Git报错-refusing to merge unrelated histories

    记Git报错-refusing to merge unrelated histories   系统:win7 git版本: 2.16.2.windows.1 问题 1.本地初始化了git仓库,放了一些 ...

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

  7. 解决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 ...

  8. Git客户端执行命令报错: fatal: Authentication failed for'xxxxx.git',但是又不弹出窗口重新输入用户名和密码的解决办法

    1.Git版本:Git-2.17.0 2.引起git报错的原因 在变更远程仓库路径的的时候,弹出过一个窗口输入用户名和密码,但是输错了,之后执行任何拉取和更新的命令都会报如下的错: fatal: Au ...

  9. 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). 解决办法一:保 ...

随机推荐

  1. vim宏录制

    宏录制 当你要重复某一个操作时,录制的宏可以很快地帮你完成任务. 准备文本 <!DOCTYPE html> <html lang="en"> <hea ...

  2. docker 安装部署 mysql(配置文件启动)

    获取 mysql 镜像 docker pull mysql:5.6 docker images 创建容器 创建宿主机 redis 容器的数据和配置文件目录 # 创建宿主机 redis 容器的数据和配置 ...

  3. vue 引入 leaflet1.4.0

    安装leaflet cnpm install leaflet@~1.4.0 --save // 在main.js 中设置如下 //引入样式文件 import 'leaflet/dist/leaflet ...

  4. spring学习日志二

    一.spring依赖注入的方式 1.通过set方法来完成注入 <bean id="student" class="com.zhiyou100.xz.spring.S ...

  5. java activity工作流

    java activity工作流 参考资料: 1.https://blog.csdn.net/jiangyu1013/article/details/73250902 2.https://blog.c ...

  6. C语言判断两个值相等

    内置类型比较直接用==判断 字符串比较要用string.h里的函数strcmp(const char *str1,const char *str2)进行比较string.h里的函数strcmp(con ...

  7. 由struts2中配置使用servlet引发的思考和复习

    Struts2拦截器到底拦截了什么? 关于struts2中的拦截器,首先再次理解其实只能过滤其中访问的action的映射!再者,因为struts中的action其实就是起到替代servlet作用的,所 ...

  8. JAVAWEB开发批量删除,SSM的几种情况

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. golang——rune

    byte 等同于int8,常用来处理ascii字符 rune等同于int32,常用来处理unicode或utf-8字符//可以处理中文

  10. CSS3 animaion 和 transition 比较

    animation是CSS3的动画属性,可以设置以下六种属性. transition是CSS3的过度属性,可以设置以下四种属性. 从属性上分析,animation可以设定循环次数. 其次,两者的触发条 ...