Skip to content

Instantly share code, notes, and snippets.

@vilanovi
Created June 11, 2021 11:35
Show Gist options
  • Save vilanovi/4eb733a4e121ad681367381c7e194229 to your computer and use it in GitHub Desktop.
Save vilanovi/4eb733a4e121ad681367381c7e194229 to your computer and use it in GitHub Desktop.
Mirrors an existing repository into a new repository
# USAGE: ./git-mirror git@domain.com:account/source.git git@domain.com: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