git 出現 fatal: refusing to merge unrelated histories 錯誤

git pull 失敗 ,提示:fatal: refusing to merge unrelated historiesgit

其實這個問題是由於 兩個 根本不相干的 git 庫, 一個是本地庫, 一個是遠端庫, 而後本地要去推送到遠端, 遠端以爲這個本地庫跟本身不相干, 因此告知沒法合併centos

具體的方法, 一個種方法: 是 從遠端庫拉下來代碼 , 本地要加入的代碼放到遠端庫下載到本地的庫, 而後提交上去 , 由於這樣的話, 你基於的庫就是遠端的庫, 這是一次updatecode

第二種方法:
使用這個強制的方法get

git pull origin master --allow-unrelated-historiesit

後面加上 --allow-unrelated-histories , 把兩段不相干的 分支進行強行合併ast

相關文章
相關標籤/搜索