Skip to content

Instantly share code, notes, and snippets.

@andybeak
Created November 4, 2018 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save andybeak/602611212950559df9c102b0d1ae20c7 to your computer and use it in GitHub Desktop.
Save andybeak/602611212950559df9c102b0d1ae20c7 to your computer and use it in GitHub Desktop.
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
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

@tylerjgarlandtest
Copy link

@febs , thanks! There also shouldn't be a space after $r " on line 6.

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