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設置也可如下: