加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

git 出现 fatal: refusing to merge unrelated histories 错误

发布时间:2020-12-14 16:34:58 所属栏目:百科 来源:网络整理
导读:背景 git pull失败,提示:? fatal: refusing to merge unrelated histories ? ? 根本原因 因为两个根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并 ? 解决方案一 git cl

背景

git pull失败,提示:?fatal: refusing to merge unrelated histories?

?

根本原因

因为两个根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并

?

解决方案一

git clone远程仓库到本地,将需要推送的内容放到该仓库下 , 然后提交上去 , 这样算是一次update操作

?

解决方案二

使用强制命令

git pull origin master --allow-unrelated-historie?

后面加上?--allow-unrelated-histories? , 把两段不相干的分支进行强行合;这里可能会进入一个编辑页面,只需要先ESC,然后敲:q!?即可

后面再push就可以了?git push -u origin master?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读