Skip to content

Instantly share code, notes, and snippets.

@nilkesede
Forked from vke-code/download-all-repos.sh
Last active January 29, 2022 23:55
Show Gist options
  • Save nilkesede/ab6c3c21302f7a51284d97400597baab to your computer and use it in GitHub Desktop.
Save nilkesede/ab6c3c21302f7a51284d97400597baab to your computer and use it in GitHub Desktop.
#!/bin/bash
# Clone all github.com repositories for a specified user/organization.
if [ $# -eq 0 ]
then
echo "Usage: $0 <type>(me|users|orgs) <user_name>"
exit;
fi
type=$1
user=$2
token="" # Your personal token here
url="https://api.github.com/$type/$user/repos?per_page=1000"
if [ $type == 'me' ]
then
url="https://api.github.com/user/repos?type=owner&per_page=999"
fi
for repo in `curl --location --request GET $url --header "Authorization: Basic ${token}" |grep ssh_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/'`;do
git clone $repo;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment