Skip to content

Instantly share code, notes, and snippets.

@ewized
Last active August 29, 2015 14:07
Show Gist options
  • Save ewized/cef444b6711366ba91a6 to your computer and use it in GitHub Desktop.
Save ewized/cef444b6711366ba91a6 to your computer and use it in GitHub Desktop.
Mirror GitHub repos, when you have oauth access keys set up, this can be set up as a cron job.
#!/bin/bash
# This will keep a list of repositories in sync.
# This is a one way parent -> fork
DATE=$(date -u +%F-%H-%M-%S)
SYNC_FOLDER=keep_sync_folder
KEY=
cd ~
if [ -d $SYNC_FOLDER ] ; then
rm -Rf $SYNC_FOLDER
echo "gone"
fi
mkdir -p $SYNC_FOLDER/$DATE
cd $SYNC_FOLDER/$DATE
# $1 = Owner
# $2 = Name
# $3 = Fork Owner
function sync_repo() {
git clone https://$KEY:[email protected]/$1/$2.git
cd $2
git push --mirror --quiet https://$KEY:[email protected]/$3/$2.git
cd ../
}
#sync_repo Owner Name Fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment