问题描述
很久之前在 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合并命令拒绝合并没有共同祖先的历史。当两个项目的历史独立地开始时,这个选项可以被用来覆盖这个安全。由于这是一个非常少见的情况,因此没有默认存在的配置变量,也不会添加。(有道翻译)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)