Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spantheslayer/831f171db1d5a11b8e4ade1605862e31 to your computer and use it in GitHub Desktop.
Save spantheslayer/831f171db1d5a11b8e4ade1605862e31 to your computer and use it in GitHub Desktop.
Leaving an Organization? Here's your safety pin! All you have to do is get 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment