Skip to content

Instantly share code, notes, and snippets.

@potter0815
Last active January 30, 2024 13:07
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save potter0815/42dda83fa1709693be36 to your computer and use it in GitHub Desktop.
Save potter0815/42dda83fa1709693be36 to your computer and use it in GitHub Desktop.
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
Copy link

Worked very well for me. Thank you!

@carnivash
Copy link

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

@jeffbabuyo
Copy link

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

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

@pdoddi
Copy link

pdoddi commented Jan 22, 2020

Thanks. it worked for me

@sa-mu-el
Copy link

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
Copy link

perfect, thanks!

@maxgfr
Copy link

maxgfr commented Apr 16, 2021

Thanks !!

@pedryvo
Copy link

pedryvo commented Nov 22, 2021

Thanks!

Copy link

ghost commented Jul 3, 2022

thank you

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