-
Notifications
You must be signed in to change notification settings - Fork 7
Merging existing repos into a monorepo
Devon Carew edited this page Aug 13, 2024
·
8 revisions
Note
The below steps have been automated by the tool in https://github.com/mosuem/merger.
(Instructions in-lined from https://github.com/dart-lang/tools/pull/100.)
Steps taken for a sample graphs
repo and target tools
monorepo:
- Get git-filter-repo:
newren $ git clone git@github.com:newren/git-filter-repo.git
- Add
git-filter-repo
toPATH
. - Fresh clone of repo that needs to be merged into a mono repo:
dart-lang $ git clone git@github.com:dart-lang/graphs.git
- Destructively rewrite the history of the repository to be in
pkgs/package_name
:
graphs $ git filter-repo --path-rename :pkgs/graphs/
- Destructively prefix all the tags:
graphs $ git filter-repo --tag-rename :graphs-
- Replace paths and links in files.
- Badges:
https://github.com/dart-lang/graphs/actions/workflows/ci.yml
->https://github.com/dart-lang/tools/actions/workflows/graphs.yml
- Remaining links, manually check if this does the right thing, otherwise insert steps above this step.
https://github.com/dart-lang/graphs
->https://github.com/dart-lang/tools/tree/main/pkgs/graphs
- Badges:
- Migrate the GitHub workflow.
- Commit with a detailed message.
- In the directory of the mono_repo, create a branch.
tools $ git checkout -b merge-graphs-package
- Add a remote for the local clone of the moving package
tools $ git remote add graphs_package /Users/dacoharkes/src/dart-lang/graphs/
tools $ git fetch graphs_package
- Merge
tools $ git merge --allow-unrelated-histories graphs_package/master -m "Merge package:graphs into shared tool repository"
- Copy the list of renamed tags into a comment on the PR.
- Create a pull request and get it reviewed. Do not submit through the github UI, since it does not allow a fast forward merge.
- If there are changes required, back out and start over (it's OK to force push to the PR branch)
- Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings.
- Push tags to github
- Follow up with a PR adding links to the top-level readme table.
- Add a commit to https://github.com/dart-lang/graphs/ with it's readme pointing to this repo
- Archive https://github.com/dart-lang/graphs/.