解决 fatal: refusing to merge unrelated histories

Git 的报错

1、fatal: refusing to merge unrelated histories

新建了一个仓库以后,把本地仓库进行关联提交、拉取的时候,出现了以下错误:git

ankobot@DESKTOP-9IUDMKP MINGW64 /e/workspace/firmware_upload/firmware_upload (master)
$ git pull
fatal: refusing to merge unrelated histories

2、解决方案

在你操做命令后面加 --allow-unrelated-histories
例如:ide

git merge master --allow-unrelated-histories
$ git pull --allow-unrelated-histories
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging .gitignore
Automatic merge failed; fix conflicts and then commit the result.

我这里因为使用了官方的 .gitignore 自动合并失败,须要手动合并以后再进行 add、commit 便可spa

若是你是git pull或者git push报fatal: refusing to merge unrelated histories
同理:
git pull origin master --allow-unrelated-histories / git pull --allow-unrelated-histories
等等,就是这样完美的解决!code

相关文章
相关标签/搜索