Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete all your github repositories
#!/bin/bash
token="Get from Github"
# Gets a list of the repositories you own (not ones granted through organisation)
curl -H "Authorization: token ${token}" https://api.github.com/user/repos?affiliation=owner | grep git_url | sed -r 's/( "git_url": "git:\/\/github.com\/)//' | sed -r 's/.git",//' > url_list.txt
# Deletes all the repositories it found on the line before
while read r;do curl -XDELETE -H 'Authorization: token ${token}' "https://api.github.com/repos/$r ";done < url_list.txt
rm url_list.txt
@febs

This comment has been minimized.

Copy link

febs commented Jan 1, 2019

Line 6 should have double quotes for the -H parameter for the ${token} variable to be substituted. :-) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.