解决Git中fatal: refusing to merge unrelated histories
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
1
2
3
這里的問題的關鍵在于: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.
1
2
3
4
5
如果你是git pull或者git push報fatal: refusing to merge unrelated histories
同理:
git pull origin master --allow-unrelated-histories
等等,就是這樣完美的解決咯!
————————————————
版權聲明:本文為CSDN博主「向小凱同學學習」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/wd2014610/article/details/80854807
總結
以上是生活随笔為你收集整理的解决Git中fatal: refusing to merge unrelated histories的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringBoot内置tomcat出现
- 下一篇: 捍卫左前转向灯不亮了怎么修?