Last active
August 29, 2015 14:07
-
-
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.
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
#!/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