Created
June 11, 2021 11:35
-
-
Save vilanovi/4eb733a4e121ad681367381c7e194229 to your computer and use it in GitHub Desktop.
Mirrors an existing repository into a new repository
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
# USAGE: ./git-mirror [email protected]:account/source.git [email protected]:account/destination.git | |
echo ""; | |
echo "Cloning repository source: $1"; | |
echo ""; | |
git clone --mirror $1 temp-folder | |
echo ""; | |
echo "Adding new origin: $2"; | |
echo ""; | |
cd temp-folder | |
git remote add new-origin $2 | |
echo ""; | |
echo "Pushing repo to: $2"; | |
echo ""; | |
git push new-origin --mirror | |
echo ""; | |
echo "Cleaning up.."; | |
echo ""; | |
cd .. | |
rm -rf temp-folder | |
echo ""; | |
echo "Done!"; | |
echo ""; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment