Skip to content

Instantly share code, notes, and snippets.

@dm
Created November 11, 2016 15:45
Show Gist options
  • Select an option

  • Save dm/627671b4d209accbcfd92db9ec1d381f to your computer and use it in GitHub Desktop.

Select an option

Save dm/627671b4d209accbcfd92db9ec1d381f to your computer and use it in GitHub Desktop.
Clone all organisation repos into current directory
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Create a Personal Access Token and add it here (replace my username with yours)
# https://github.com/settings/tokens
CREDS=dm:TOKEN
ORG=${ORG:=sansible}
PAGES=${PAGES:=60}
for i in $(seq 1 $PAGES);
do
curl -u $CREDS -s "https://api.github.com/orgs/$ORG/repos?page=$i&per_page=100" | ruby -rubygems -e \
'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}';
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment