-
Notifications
You must be signed in to change notification settings - Fork 7
Merging existing repos into a monorepo
Devon Carew edited this page Sep 23, 2024
·
8 revisions
- Get git-filter-repo
git clone https://github.com/newren/git-filter-repo.git
- Fresh clone of repo that needs to be merged into a mono repo:
dart-lang $ git clone [email protected]:dart-lang/graphs.git
Automatic steps using package:trebuchet:
- Check that the local monorepo is in a fresh state.
- Run
git clone [email protected]:dart-lang/ecosystem.git
cd ecosystem/pkgs/trebuchet
dart run bin/trebuchet.dart \
--input-name graphs \
--branch-name master \
--input-path ~/projects/graphs/ \
--target tools \
--target-path ~/projects/tools/ \
--git-filter-repo ~/tools/git-filter-repo \
--dry-run
- Do the same without the dry-run.
- Execute the remaining steps shown in the terminal.
(Instructions in-lined from https://github.com/dart-lang/tools/pull/100.)
Steps taken for a sample graphs
repo and target tools
monorepo:
- Add
git-filter-repo
toPATH
. - 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)
- Merging the PR:
- Update the repo PR merge settings to enable "Allow merge commits"
- Merge with a fast forward merge to the main branch ("Create a merge commit"); do not squash and merge
- Update the repo PR merge settings to only "Allow squash merging"
- 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/.