解決 fatal: refusing to merge unrelated histories

Git 的報錯

一、fatal: refusing to merge unrelated histories

新建了一個倉庫之後,把本地倉庫進行關聯提交、拉取的時候,出現瞭如下錯誤:

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

二、解決方案

在你操作命令後面加 --allow-unrelated-histories
例如:

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 即可

如果你是git pull或者git push報fatal: refusing to merge unrelated histories
同理:
git pull origin master --allow-unrelated-histories / git pull --allow-unrelated-histories
等等,就是這樣完美的解決!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章