Skip to content

Instantly share code, notes, and snippets.

@ConnerAiken
Created March 16, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConnerAiken/df03dcae1a853f8a110339e568e79995 to your computer and use it in GitHub Desktop.
Save ConnerAiken/df03dcae1a853f8a110339e568e79995 to your computer and use it in GitHub Desktop.
Sync two git repositories
#!/bin/bash
# REPO_NAME=<repo>.git
# ORIGIN_URL=git@<host>:<project>/$REPO_NAME
# REPO1_URL=git@<host>:<project>/$REPO_NAME
rm -rf $REPO_NAME
git clone --bare $ORIGIN_URL
cd $REPO_NAME
git remote add --mirror=fetch repo1 $REPO1_URL
git fetch origin --tags git fetch repo1 --tags
git push origin --all git push origin --tags
git push repo1 --all git push repo1 --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment