Skip to content

Instantly share code, notes, and snippets.

@joeangel
Last active October 9, 2019 08:09
Show Gist options
  • Save joeangel/4e350cae541b5c8a950ec9cecf2648a6 to your computer and use it in GitHub Desktop.
Save joeangel/4e350cae541b5c8a950ec9cecf2648a6 to your computer and use it in GitHub Desktop.
Use this trick to bulk delete repos in an organization

Bulk delete repos in an organization

Remove all repons in an organization

USERNAME="joeangel"
PASSWORD="YOUR PASSWORD"
ORG="THE ORG name"
curl -u $USERNAME:$PASSWORD "https://api.github.com/orgs/$ORG/repos?page=1&per_page=100" | jq '.[].full_name' | tr -d '\r' | xargs -I '{}' curl -u $USERNAME:$PASSWORD -XDELETE https://api.github.com/repos/'{}'

Remove all repos exclude which name including the string gitlab in an organization

USERNAME="joeangel"
PASSWORD="YOUR PASSWORD"
ORG="THE ORG name"
curl -u $USERNAME:$PASSWORD "https://api.github.com/orgs/$ORG/repos?page=1&per_page=100" | jq '.[].full_name' | tr -d '\r' | grep -v 'gitlab' | xargs -I '{}' curl -u $USERNAME:$PASSWORD -XDELETE https://api.github.com/repos/'{}'

The part grep -v 'gitlab' meas: ignore the repos which name including the string gitlab

References

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