Skip to content

Instantly share code, notes, and snippets.

@juliancorrea
Last active November 20, 2021 18:48
Show Gist options
  • Save juliancorrea/e472175381370ae7d681ec59bb22ed65 to your computer and use it in GitHub Desktop.
Save juliancorrea/e472175381370ae7d681ec59bb22ed65 to your computer and use it in GitHub Desktop.
git-clone-all.sh
# The first parameter $1 must be orgs or users
# The second one $2 must be your username or orgnatization name
# The third one $3 must be your username
# The fourth one $4 must be your github auth token
#
# Set CNTX=users and NAME=yourusername, to download all your repositories.
# Set CNTX=orgs and NAME=yourorgname, to download all repositories of your organization.
#
# Script inspired by https://stackoverflow.com/questions/19576742/how-to-clone-all-repos-at-once-from-github/32833411#32833411
#
# Use example:
# sh git-clone-all.sh orgs MY_ORGNAME MY_USER_NAME MY_GITHUB_TOKEN
CNTX=$1; NAME=$2; PAGE=1
curl -u $3:$4 "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" | grep -e 'clone_url*' |
cut -d \" -f 4 | xargs -L1 git clone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment