解決Git中fatal: refusing to merge unrelated histories


原文鏈接: https://blog.csdn.net/wd2014610/article/details/80854807

Git的報錯

在使用Git的過程中有時會出現一些問題,那么在解決了每個問題的時候,都需要去總結記錄下來,下次不再犯。

一、fatal: refusing to merge unrelated histories

今天在使用Git創建項目的時候,在兩個分支合並的時候,出現了下面的這個錯誤。

~/SpringSpace/newframe on  master ⌚ 11:35:56 $ git merge origin/druid fatal: refusing to merge unrelated histories

這里的問題的關鍵在於:fatal: refusing to merge unrelated histories
你可能會在git pull或者git push中都有可能會遇到,這是因為兩個分支沒有取得關系。那么怎么解決呢?

二、解決方案

在你操作命令后面加--allow-unrelated-histories
例如:
git merge master --allow-unrelated-histories

~/SpringSpace/newframe on  druid ⌚ 11:36:49 $ git merge master --allow-unrelated-histories Auto-merging .gitignore CONFLICT (add/add): Merge conflict in .gitignore Automatic merge failed; fix conflicts and then commit the result.

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM