How to migrate multiple repositories into a mono-repo while maintaining commit history?

こ雲淡風輕ζ 提交于 2019-12-04 14:33:36

Yes, you can use git commands to achieve.

Migarte two repos into a monorepo into subfolder project1 and project2, you need to move files into project1/project2 folder of a repo, commit changes and then combine them together. Detail steps as below:

1. Move files into project1 and project2 folders separately

In the first repo (such as repo1), move files into project1 folder as below:

# In local repo1 
mkdir project1
mv * project1
git add .
git command -m 'move files into project1 folder'
git push

In the second repo (such as repo2), move files into project2 folder as below:

# In local repo2
mkdir project2
mv * project2
git add .
git command -m 'move files into project2 folder'
git push

2. migrate the two repos into a momorepo

In any of a local repo (such as in local repo1), execute below commands:

# In local repo1
git remote add repo2 <URL for repo2> -f
git pull repo2 master --allow-unrelated-histories
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!