Skip to content

Instantly share code, notes, and snippets.

@m87h
Created March 18, 2014 21:03
Show Gist options
  • Save m87h/9629563 to your computer and use it in GitHub Desktop.
Save m87h/9629563 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ]; then
echo "usage: mirror-git <source repo> <local cache> <destination repo>" >&2
exit 1
fi
SOURCE=$1
LOCAL_CACHE=$2
DESTINATION=$3
if [ -d $LOCAL_CACHE ]; then
cd $LOCAL_CACHE
git remote update
git push --mirror $DESTINATION
else
git clone --mirror $SOURCE $LOCAL_CACHE
cd $LOCAL_CACHE
git push --mirror $DESTINATION
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment