今天在本地提交仓库到远程仓库的时候,在合并远程仓库和本地仓库git出现
fatal: refusing to merge unrelated histories
以上错误,在网上搜了下,原来是本地仓库和远程仓库是两个不相干的仓库,然后把本地仓库推到远程仓库,远程仓库觉得这个和自己不相干,所以告知无法合并。
具体的拒绝方法有两个:
第一种是从远程pull仓库到本地,然后再从本地提交代码到远程仓库,这样的话,基于的库就是远程的仓库了。
第二种就是强行合并两个仓库的代码
git pull origin master --allow-unrelated-histories
如果是push也可以用同样的方法。
具体可以参考:https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase
原文:https://www.centos.bz/2018/03/git-出现-fatal-refusing-to-merge-unrelated-histories-错误/