我是靠谱客的博主 丰富菠萝,这篇文章主要介绍git出现refusing to merge unrelated histories解决方案,现在分享给大家,希望可以做个参考。

问题重现

在使用git的时候,如果刚开始本地已经有了仓库,但是并没有和远程仓库关联,这时如果直接设置remote或者pull远程仓库代码,在合并的时候会出现refusing to merge unrelated histories提示。


操作步骤

首先在已有的本地文件夹初始化git:

git init

然后设置远程仓库地址:

git remote add origin http://github.com/your.git

拉取远程仓库

git fetch origin

合并仓库

git merge origin/master
fatal: refusing to merge unrelated histories

这时就报错了,提示我们没有合并关联的历史记录


解决方案

在拉取远程仓库的时候使用--allow-unrelated-histories就可以了

git pull origin master --allow-unrelated-histories

最后

以上就是丰富菠萝最近收集整理的关于git出现refusing to merge unrelated histories解决方案的全部内容,更多相关git出现refusing内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部