Created
November 4, 2018 14:25
-
-
Save andybeak/602611212950559df9c102b0d1ae20c7 to your computer and use it in GitHub Desktop.
Delete all your github repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 6 should have double quotes for the -H parameter for the ${token} variable to be substituted. :-) Thanks