steps:
1.克隆仓库1:git clone repo1
2.克隆仓库2:git clone repo2
3:在仓库2中添加远程仓库1到仓库1,命名为other
cd repo2
git remote add other ../repo1/
4.检出历史信息
git fetch other
5.基于other的master分支创建并检出新的分支,名字为repo1_test (名字自己随意)
git checkout -b repo1 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)。