Preparation
- Source repo should have as many branches and PRs closed or merged as possible
- Rest of PRs should be merged with master just before migration begins
Prepare the initial commit of the migrated repo (master)
- Archive source repo
- Go to target directory in monorepo
- Clone source repo into correctly named folder in monorepo
cdto repo and make all necessary changes for migration to monorepo (e.g. renaming)- Commit all changes INSIDE the cloned repo on local master (commit name doesn't matter, DO NOT PUSH)
mv .git /tmp/reponame.gitgit add -A .git commit -m "migrate repo to monorepo"
Copy remaining branches/PRs individually (repeat this cycle for each)
0. cd to the source repo directory in the monorepo
mv /tmp/reponame.git .git(switch git context back to source repo)git checkout --force PR-123(switch to PR branch)git merge masterand solve merge conflicts, and add all changed files (merge in changes from step 4 above)mv .git /tmp/reponame.git(switch git context back to monorepo)git checkout -b reponame/PR-123(create a new branch in monorepo to store this PR)git add --all --force .(add all changes, including ignored files)git status(double-check all files were added and removed correctly)git commit -m "Original PR title (Repo#123)"(create a squash commit for this PR)gh pr create(create and push a PR for this branch)git checkout --force -(go back to original branch in monorepo)git reset --hard HEAD(clear out any lingering changes)mv /tmp/reponame.git .git(switch git context back to source repo)git checkout --force master(clear out any lingering changes)mv .git /tmp/reponame.git(switch git context back to monorepo)- Repeat