Last active
July 11, 2023 23:32
-
-
Save frainfreeze/f69de1a52024b02fc308afe28ea764af to your computer and use it in GitHub Desktop.
Merge github repos, preserving history
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
Clone and merge github repo into archive as a subfolder, preserving commit history |
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
# before running the script prepare archhive folder in the same location | |
export REPONAME={HelloWorldRepo} | |
export GHUSER={UsersUsername} | |
git clone git@github.com:$GHUSER/$REPONAME.git | |
cd $REPONAME | |
git filter-repo --to-subdirectory-filter $REPONAME | |
cd ../archive | |
git remote add $REPONAME ../$REPONAME | |
git fetch $REPONAME --tags | |
git merge --allow-unrelated-histories $REPONAME/master -m"merge" | |
git remote remove $REPONAME | |
git push | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment