Created
January 6, 2016 18:03
-
-
Save heroqu/c7704535d74c0e66d60b to your computer and use it in GitHub Desktop.
Bash script for bulk deletion of repos under your github account
This file contains hidden or 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 | |
| ## Based on and inspired by | |
| # https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45 | |
| ## Vars | |
| # 1. Your github user name | |
| USERNAME=john | |
| # 2. Token with delete_repo priviledge | |
| # to obtain token just go to your github account to the page | |
| # https://github.com/settings/tokens/new | |
| # ( don't forget to check 'delete_repo' checkbox before generating ) | |
| # put the token string here between single quotes instead of x-es. | |
| TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
| # 3. List of repos to be deleted. | |
| # - plain text file in the same directory as this script with one repo name per line | |
| # (don't put fully qualified repo names, just the part after last slash). | |
| # Change the file name here if the file is named differently. | |
| REPO_LIST_FILE='./repolist.txt' | |
| ## Get rid of that crap | |
| cat ${REPO_LIST_FILE} | xargs -I {} curl -X DELETE -H "Authorization: token ${TOKEN}" https://api.github.com/repos/${USERNAME}/{} | |
| ## PS. | |
| # The blog post mentioned in the beginning explaines how to make a list of your github repos in a easier way using Chrome browser extention. | |
| # This can really help if you need to delete dozens of repos (stale forks e.g.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment