问题
repo1 repo2是两个无关联的仓库,需要合并并保留两者的提交历史
git checkout repo1 repo1/master
git checkout repo2 repo2/master
git merge repo1
直接尝试合并时会报错
fatal: refusing to merge unrelated histories
解决步骤
- 使用参数–allow-unrelated-histories合并
git merge repo1 --allow-unrelated-histories
- 处理冲突文件
如果存在冲突文件会报信息如下
CONFLICT (add/add): Merge conflict in README.md
Auto-merging README.md
Automatic merge failed; fix conflicts and then commit the result.
修改处理好文件冲突内容后,将文件冲突标记为已解决
- 提交所有冲突文件/从repo1合并新增的文件