snippets

Clone all repositories of a GitHub team

First, ensure you have your GitHub token available. If you are using a .netrc, you can acquire it from there:

GITHUB_TOKEN=`cat ~/.netrc | grep 'machine github.com' | awk '{ print $6; }'`

Then, using the organization name and team slug, clone all repositories:

ORG=my-org
TEAM=my-team
http https://api.github.com/orgs/${ORG}/teams/${TEAM}/repos\?per_page\=100 \
    Authorization:"token ${GITHUB_TOKEN}" | jq '.[].clone_url' | xargs -I@ git clone @ --depth 1