前言
Git执行pull命令时报错:fatal: refusing to merge unrelated histories
原因
可能是因为当前仓库不是从clone得到的,而是通过init创建的,导致当前绑定的远端仓库与需要pull的远端仓库无关联
解决问题
方法一
- 重新clone项目,将源代码迁移到clone的项目中
方法二
- 通过
--allow-unrelated-historie
参数把两段不相干的分支进行强行合并
1
| git pull origin master --allow-unrelated-historie
|
完成
参考文献
腾讯云——小菠萝测试笔记