git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
来源:互联网 发布:软件二次开发端口 编辑:程序博客网 时间:2024/06/05 05:03
本文来源:http://blog.csdn.net/trochiluses/article/details/10100719
1.出错场景:
协同开发时,我们从远程服务器上pull下代码的时候,出现以下提示信息:
Auto Merge Failed; Fix Conflicts and Then Commit the Result.
2.原因分析:
利用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 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
本文来源:http://blog.csdn.net/trochiluses/article/details/10100719
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- git 使用场景一,pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- git常见问题之git pull时Automatic merge failed; fix conflicts and then commit the result.
- git: Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- 芒果iOS开发之 CONFLICT (content): AutoMatic merge failed;fix conflicts and then commit the result.
- Fix git “not currently on any branch” after merge conflicts
- git pull 报错:Your configuration specifies to merge with the ref 'master'from the remote
- git---如何解决git pull之后报错:Please enter a commit to explain why this merge is necessary?(merge branch)
- eclipse git报错git The current branch is not configured for pull No value for key branch.master.merge
- git pull报错refusing to merge unrelated histories
- merge conflicts in Git
- 【Git】git rebase+fix conflict+git add+git rebase --continue或git merge+fix conflict+git add+git commit
- eclipse git 报错:the current branch is not configured for pull No value for key branch.xxx.merge found
- git: fetch and merge, don’t pull
- Git分支 and Pull&Fetch&Merge
- mysql升级之路
- hdu 1950
- Android实现弹出输入法时,顶部固定,中间部分上移的效果
- 官方建议的python的书写惯例
- Berkeley DB事务篇
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- SQL Server 存储过程
- Firefox(火狐浏览器)丰富的Web开发辅助插件
- 一些开源技术
- HTML <input> 标签的 readonly 属性
- Android Toast显示动画
- 如何同时启动多个Tomcat服务器
- UIView的autoresizingMask属性
- HEVC中CU分割示例