Skip to content

Instantly share code, notes, and snippets.

@lemieszek
Created October 12, 2021 07:43
Show Gist options
  • Save lemieszek/d12cec87844fbf43de026eda13da3945 to your computer and use it in GitHub Desktop.
Save lemieszek/d12cec87844fbf43de026eda13da3945 to your computer and use it in GitHub Desktop.
Get all repos from GitHub user or org
# Auth token is optional
# Get user repos
NAME="username"; PAGE=1; TOKEN="your_personal_token";
curl -H "Authorization: token $TOKEN" "https://api.github.com/users/$NAME/repos?page=$PAGE&per_page=100" |
grep -e 'git_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
# Get org repos
NAME="orgname"; PAGE=1; TOKEN="your_personal_token";
curl -H "Authorization: token $TOKEN" "https://api.github.com/orgs/$NAME/repos?page=$PAGE&per_page=100" |
grep -e 'git_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
# use sed to change it to ssh clone
sed 's/git:\/\//git@/g' |
sed 's/github.com\//github.com:/g' |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment