Created
March 5, 2019 12:19
-
-
Save berstend/7d55d2f8232fa1c34fb797485ffb667e to your computer and use it in GitHub Desktop.
Make a monorepo with existing repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Before: | |
# (Assuming you standard branch is development in the mono repo) | |
# git checkout -b add-services | |
githubOrg=FOOBAR | |
repoList="api backend-service frontend" | |
repoBranch="development" | |
serviceDir=services # local directory to pull the other repos in | |
for repoName in $(echo $repoList); do | |
echo "Adding ${repoName}.." | |
git subtree add --prefix=${serviceDir}/${repoName} https://github.com/${githubOrg}/${repoName} ${repoBranch} | |
done | |
# After: | |
# git checkout development | |
# git rebase add-services | |
# git push --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a surprising amount of outdated or just plain incorrect info on the internet regarding this. The above will preserve the history of each service so git blame/lens continues to work. The heavy lifting is done by
git subtree add
.