Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mirror Git repositories
# This commands to keep in sync a clone of a Git repository
# 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
You can’t perform that action at this time.