git 合並兩個倉庫


steps:

1.克隆倉庫1:git clone repo1


2.克隆倉庫2:git clone repo2


3:在倉庫2中添加遠程倉庫1,命名為other

cd repo2
git remote add other ../repo1/

4.檢出歷史信息
git fetch other

5.基於other的master分支創建並檢出新的分支,名字為repo1_test (名字自己隨意)
git checkout -b repo1_test other/master

6.切到倉庫2的主線分支
git checkout master

7.合並基於other創建的分支repo1-test到倉庫2的master分支上
git merge repo1_test  --allow-unrelated-histories

8.提交到代碼庫
說明:提交到gerrit:git push origin HEAD:refs/for/master (需要設置forge author identify 和forge commiter identify)

    但是會產生很多提交記錄,要一條一條合入,很麻煩,所以建議強制push入庫(參考:https://blog.csdn.net/liuxu0703/article/details/54343626)。

gerrit設置也可如下:

 


免責聲明!

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



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