TODO
- we can keep the history under the subdirectory via
--to-subdirectory-filter
git filter-repo --source "$tmp_dir/$package" --target "$tmp_dir/$package" --to-subdirectory-filter "packages/$package" --commit-callback "commit.message += b'\n\nPreMonorepoCommit: https://github.com/$repository/commit/' + commit.original_id + b'\n'"
git merge --allow-unrelated-historiesto merge multiple repositories without common parent commitgit filter-repoto inject links to the original commit on Githubgit tagto rename existing tags
- original repositories
- result
shellcheck -x init-monorepo.sh
# initialize monorepo locally
bash init-monorepo.sh |& tee -a init-monorepo.log
# push to remote if the result looks okay
cd demo-init-monorepo
git remote add origin [email protected]:hi-ogawa/demo-init-monorepo.git
git push origin init-monorepo # --force
git push origin --tags # --force- reset tags (when testing repeatedly in the same repository)
git fetch
git tag -l | xargs -n 1 git push --delete origin
git tag -l | xargs -n 1 git tag -d
- port old diff to monorepo (e.g. to migrate old PRs)
# Create diff in an old repository (e.g. diff from master to HEAD in "some-module" repository)
git diff master > some-module.diff
# Convert diff
python prefix-diff.py packages/some-module < some-module.diff > some-module.monorepo.diff
# Apply diff in monorepo
git apply some-module.monorepo.diff