当 git pull 碰到拒绝合并无关历史
2017-09-03 13:05
344 查看
原文链接:当 git pull 碰到拒绝合并无关历史
突然有天,我想把本地的一个项目传上去,然后就碰到了这样一个问题!
当我 添加远程仓库 后准备提交代码时,git 提示我请先使用
没毛病,老铁,就应该这样!
但当我
对此,git 的 官方文档 是这样描述的:
By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.
默认情况下,git合并命令拒绝合并没有共同祖先的历史。当两个项目的历史独立地开始时,这个选项可以被用来覆盖这个安全。由于这是一个非常少见的情况,因此没有默认存在的配置变量,也不会添加。(有道翻译)
比如这位网友碰到的问题 Git没有共同祖先的两个分支如何合并 , 远程仓库和本地的差异很零散而且似乎都很重要,使用
Git refusing to merge unrelated histories(建议翻墙)
Git没有共同祖先的两个分支如何合并?
问题描述
很久之前在 github 上建了个仓库,里面只有一个README.md文件。
突然有天,我想把本地的一个项目传上去,然后就碰到了这样一个问题!
当我 添加远程仓库 后准备提交代码时,git 提示我请先使用
git pull。
没毛病,老铁,就应该这样!
但当我
git pull origin master时就出现了这样一条错误:
fatal: refusing to merge unrelated histories // 拒绝合并无关历史
解决办法
在拉取时使用以下命令:git pull origin master --allow-unrelated-histories
对此,git 的 官方文档 是这样描述的:
By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.
默认情况下,git合并命令拒绝合并没有共同祖先的历史。当两个项目的历史独立地开始时,这个选项可以被用来覆盖这个安全。由于这是一个非常少见的情况,因此没有默认存在的配置变量,也不会添加。(有道翻译)
总结
本文所提到的情况只是一个很简单的问题,--allow-unrelated-histories似乎并不能解决所有人的麻烦。
比如这位网友碰到的问题 Git没有共同祖先的两个分支如何合并 , 远程仓库和本地的差异很零散而且似乎都很重要,使用
--allow-unrelated-histories合并出的结果可能就会不尽人意,所以还要具体情况具体分析喽!
参考
git无法pull仓库refusing to merge unrelated historiesGit refusing to merge unrelated histories(建议翻墙)
Git没有共同祖先的两个分支如何合并?
相关文章推荐
- git配置过程中fatal:拒绝合并无关的历史
- git fatal: 拒绝合并无关的历史的错误解决
- git提交 出现拒绝合并无关历史 解决
- 合并两个git仓库,并保留每个仓库的历史
- git clone 分支的新建与合并及更新被拒绝被拒绝解决方法
- git合并历史提交
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)
- git合并分支报错 :Branch 'master' is protected and commits must be merged through pull request
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- git无法pull仓库refusing to merge unrelated histories 标签: gitgit合并git-pull 2016-10-03 09:04 48563人阅读 评论(
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- 11_Eclipse中演示Git版本的创建,历史版本的修改,创建分支,合并历史版本和当前版本
- git---基本操作、新建分支,合并分支branch到主干master ,git pull ,git push
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- Git 初接触 (七)git pull 拉取远程最新更新并合并