Skip to content

Instantly share code, notes, and snippets.

@GromNaN
Created August 30, 2012 15:54
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 GromNaN/3531561 to your computer and use it in GitHub Desktop.
Save GromNaN/3531561 to your computer and use it in GitHub Desktop.
Mirror Git repositories
# 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