关于git pull 时出现 fatal refusing to merge unrelated histories的解决办法

git pull 出现 fatal: refusing to merge unrelated histories

git pull 命令------相当于是从远程获取最新版本并merge到本地

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

解决办法:强制下拉合并

git pull origin master --allow-unrelated-histories

后面加上 --allow-unrelated-histories , 把两段不相干的 分支进行强行合并

最后在git push

站在巨人的肩膀上摘苹果:

原文请点击------https://www.centos.bz/2018/03/git-%E5%87%BA%E7%8E%B0-fatal-refusing-to-merge-unrelated-histories-%E9%94%99%E8%AF%AF/​​​​​​​

猜你喜欢

转载自www.cnblogs.com/eternityz/p/12273124.html