Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
clone all private repos of an organization
#!/bin/bash
#requires jq -> http://stedolan.github.io/jq/
#optional change working_dir
working_dir=${1-$(pwd)}
cd $working_dir
user="github_username"
token="application token"
organization="Organization_Name"
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
@mdobroggg

This comment has been minimized.

Copy link

@mdobroggg mdobroggg commented May 6, 2019

Worked very well for me. Thank you!

@carnivash

This comment has been minimized.

Copy link

@carnivash carnivash commented Jun 4, 2019

For me, no good: curl: (23) Failed writing body (0 != 1370)

@jeffbabuyo

This comment has been minimized.

Copy link

@jeffbabuyo jeffbabuyo commented Jan 9, 2020

For me, no good: curl: (23) Failed writing body (0 != 1370)

you'll have to install jq first before it will work

@pdoddi

This comment has been minimized.

Copy link

@pdoddi pdoddi commented Jan 22, 2020

Thanks. it worked for me

@BL-SG

This comment has been minimized.

Copy link

@BL-SG BL-SG commented Jan 29, 2020

Worked flawlessly for me on windows, Downloaded jq.exe and placed it in the same file as the script.
Then changed line 13 to "./jq.exe" rather then "jq" and set it on its way using Git Bash "sh cloneall.sh"
Thanks!

@tafi-kevin

This comment has been minimized.

Copy link

@tafi-kevin tafi-kevin commented Feb 12, 2020

perfect, thanks!

@maxgfr

This comment has been minimized.

Copy link

@maxgfr maxgfr commented Apr 16, 2021

Thanks !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment