Clone all GitHub repositories for a username
January 27, 2016

I often need to backup all of my GitHub repositories to a folder. Here is a easy script to make a backup of all your repositories. It clones all of your repositories into a folder with the current date and time.

Save the script as any name you would like. Here is the code:

FOLDER=$(date +%B-%d-%Y_%I-%M-%p)
rm -rf $FOLDER
mkdir $FOLDER

curl "$USER/repos?page=$PAGE&per_page=100" | grep -e 'git_url*' | cut -d \" -f 4 | xargs -L1 git clone

Chmod the script as executable.

Call this script with the argument being your username. Example: ./ geek1011 This would backup all of my repositories assuming I named the script

I hope you find this useful.

Patrick G
Patrick G
I like to write code. I love open source software. I like to self-host stuff.