(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)
-
Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories
-
Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.
-
Save that list to some path
-
The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.
-
Register a new personal access token with a 'delete_repo perm' https://github.com/settings/tokens/new
-
Copy the access_token and run the following line replacing xxx with your access token.
Linux and OS X :
while read r;do curl -XDELETE -H 'Authorization: token xxx' "https://api.github.com/repos/$r ";done < repos
Windows:
get-content D:\repolist.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method “DELETE” -Headers @{"Authorization"="token xxx"} }
I have only tested this script on Linux.
Have fun :)
@dawesi, org repos should be supported. Do you have permissions to edit the repos in the org? Alternatively, are they private org repos?
If they are private, there is an open PR I need to review which should add support for those
Edit:
I've deployed the PR with support for Private Org repos here: https://repo-remover-op56z4vb4-moollaza.vercel.app/
The PR with the change is here for anyone interested: moollaza/repo-remover#182