其他分享
首页 > 其他分享> > git报错:refusing to merge unrelated histories 的解决方法

git报错:refusing to merge unrelated histories 的解决方法

作者:互联网

文章目录


#事故现场

将本地代码添加到远程仓库,然后pull远程仓库代码时,报错:

$ git remote add origin http://192.168.1.183/git/pstest.git
$ git pull origin master
fatal: refusing to merge unrelated histories

错误的意思是:(拒绝合并不相关的历史)

#解决方法

出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库。假如我之前是直接clone的方式在本地建立起远程git仓库的克隆,本地仓库就不会有这问题了。
最终发现可以在pull命令后紧接着使用--allow-unrelated-history选项来解决问题(该选项可以合并两个独立启动仓库的历史)。

$ git pull origin master --allow-unrelated-histories

标签:origin,pull,git,仓库,refusing,histories,unrelated,报错
来源: https://blog.csdn.net/willingtolove/article/details/113186866