Created
August 30, 2012 15:54
-
-
Save GromNaN/3531561 to your computer and use it in GitHub Desktop.
Mirror Git repositories
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
# This commands to keep in sync a clone of a Git repository | |
ORIGIN=https://github.com/symfony/symfony.git | |
MIRROR=git@gitlab.xxx.com | |
BARE=~/mirror/symfony.git | |
# First clone | |
git clone --bare ${ORIGIN} ${BARE} | |
cd ${BARE} | |
git remote rm origin && git remote add --mirror origin ${ORIGIN} | |
# Update Clone | |
cd ${BARE} | |
git branch --no-color | grep -v \* | xargs git branch -D | |
git fetch origin "+refs/heads/*:refs/heads/*" | |
# Push to mirror | |
cd ${BARE} | |
git push --mirror ${MIRROR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment