Skip to content

Instantly share code, notes, and snippets.

@phsantiago32
Last active November 22, 2021 14:02
Show Gist options
  • Save phsantiago32/87be43a185e2d7982866b0615bc2f268 to your computer and use it in GitHub Desktop.
Save phsantiago32/87be43a185e2d7982866b0615bc2f268 to your computer and use it in GitHub Desktop.
Script for cloning all repositories from a specific organization
#!/bin/bash
#requires jq -> http://stedolan.github.io/jq/
#optional change working_dir
working_dir=${1-$(pwd)}
cd $working_dir
user="YOUR_USER"
token="YOUR_GH_TOKEN"
organization="YOUR_ORGANIZATION"
repo_list=$(curl https://api.github.com/orgs/$organization/repos?type=private\&per_page=100 -u ${user}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')
for repo in $repo_list
do
echo "Repo found: $repo"
git clone $repo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment