Skip to content

Instantly share code, notes, and snippets.

@sandipndev
Last active October 19, 2021 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sandipndev/b08c546e5b055b3b9e3bbed8bccd0b8e to your computer and use it in GitHub Desktop.
Save sandipndev/b08c546e5b055b3b9e3bbed8bccd0b8e to your computer and use it in GitHub Desktop.
Here's your safety pin. All your repositories via an Access Token!
#!/bin/bash
# Organization Name
echo -n "Enter Organization Slug: "
read ORG
# Access Token
echo -n "Enter GitHub Access Token: "
read GH_ACCESS_TOKEN
# Downloading and parsing the list of ssh clone urls
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${GH_ACCESS_TOKEN}" https://api.github.com/orgs/${ORG}/repos?per_page=100 | jq --raw-output -c '.[].full_name?' > repos
# Download each repo
while IFS= read -r repo; do
git clone https://$GH_ACCESS_TOKEN:x-oauth-basic@github.com/$repo
done < repos
# Cleanup
rm repos
@spantheslayer
Copy link

Nice

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