Last active
January 27, 2023 10:29
-
-
Save skseth/b56ee18f6d4a225ca4ff519bbf124a8e to your computer and use it in GitHub Desktop.
Merging repos into a monorepo
This file contains 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
# SRC_REPO, TGT_REPO are relative to current directory | |
SRC_REPO=$1 | |
TGT_REPO=$2 | |
DIR_NAME=$3 | |
BRANCH_NAME=$4 | |
pushd $SRC_REPO | |
git filter-repo --to-subdirectory "$DIR_NAME" # replace w/ your dir name | |
popd | |
pushd $TGT_REPO | |
git config pull.rebase false # make sure this is set | |
git remote add $BRANCH_NAME ../$SRC_REPO # | |
git pull $BRANCH_NAME main --allow-unrelated-histories | |
git remote rm $BRANCH_NAME | |
You have to install git filter-repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment