Skip to content

Instantly share code, notes, and snippets.

@brianherman
Last active June 4, 2018 22:42
Show Gist options
  • Save brianherman/11036e2466d4c5843b87acdbcc1ca735 to your computer and use it in GitHub Desktop.
Save brianherman/11036e2466d4c5843b87acdbcc1ca735 to your computer and use it in GitHub Desktop.
delete github
#pip install pygithub
#python delete.py <username> <token>
#https://github.com/settings/tokens
#Create a token with delete permission and all other repo permission
#https://i.imgur.com/1mrTjTJ.png
import sys
from github import Github
username = sys.argv[1]
token = sys.argv[2]
g = Github(username, token)
for repo in g.get_user().get_repos():
if repo.private:
yorn = input("Are you sure you want to delete {} (Y/N)? ".format(repo.name))
if yorn.upper() == 'Y':
try:
repo.delete()
print('deleted {}'.format(repo.name))
except:
print('error with delete'.format(repo.name))
import traceback
traceback.print_exc()
@evandrix
Copy link

evandrix commented Jun 4, 2018

if repo.private == True: => if repo.private:

@brianherman
Copy link
Author

Thanks I have changed that

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