引用
git pull 失敗 ,提示:fatal: refusing to [merge](https://www.centos.bz/tag/merge/) unrelated histories
其實(shí)這個(gè)問題是因?yàn)?兩個(gè) 根本不相干的 git 庫, 一個(gè)是本地庫, 一個(gè)是遠(yuǎn)端庫, 然后本地要去推送到遠(yuǎn)端, 遠(yuǎn)端覺得這個(gè)本地庫跟自己不相干, 所以告知無法合并
具體的方法, 一個(gè)種方法: 是 從遠(yuǎn)端庫拉下來代碼 , 本地要加入的代碼放到遠(yuǎn)端庫下載到本地的庫, 然后提交上去 , 因?yàn)檫@樣的話, 你基于的庫就是遠(yuǎn)端的庫, 這是一次update了
第二種方法:
使用這個(gè)強(qiáng)制的方法
git pull origin [master](https://www.centos.bz/tag/master/) --allow-unrelated-histories
后面加上 --allow-unrelated-histories , 把兩段不相干的 分支進(jìn)行強(qiáng)行合并
后面再push就可以了 [git push](https://www.centos.bz/tag/git-push/) [gitlab](https://www.centos.bz/tag/gitlab/) master:init
gitlab是別名 , 使用
git remote add gitlab ssh://xzh@192.168.1.91:50022/opt/gitrepo/withholdings/WithholdingTransaction
master是本地的branch名字
init是遠(yuǎn)端要推送的branch名字
本地必須要先add ,commit完了 才能推上去
關(guān)于這個(gè)問題,可以參考http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories。
在進(jìn)行g(shù)it pull 時(shí),添加一個(gè)可選項(xiàng)
git pull origin master --allow-unrelated-histories
============================================================================================================================
