https:\/\/github.com\/settings\/tokens\/new<\/a> and create a new token. I used delete-github-forks as the Note field.<\/p>\n\n\n\nSet the public_repo and delete_repo permissions for the token.<\/p>\n\n\n\n
Generate the token and then make sure you copy the token and store it securely<\/strong> (I use 1Password).<\/p>\n\n\n\n <\/figure>\n\n\n\nConfigure delete-github-forks<\/h3>\n\n\n\n Clone the repo.<\/p>\n\n\n\n
$ cd [some directory you want the repo to be stored]\n$ git clone https:\/\/github.com\/yangshun\/delete-github-forks.git\n$ cd delete-github-forks<\/code><\/pre>\n\n\n\nInstall dependencies.<\/p>\n\n\n\n
$ npm install<\/code><\/pre>\n\n\n\n <\/figure>\n\n\n\nConfigure the credentials to be used against GitHub.<\/p>\n\n\n\n
$ cp src\/config.json.example src\/config.json\n$ vim src\/config.json [I like TextMate, so normally I am lazy and just use the mate command]<\/code><\/pre>\n\n\n\nSpecify your GitHub username and the token you generated earlier.<\/p>\n\n\n\n
Fetch the list of forks<\/h2>\n\n\n\n$ cd src\n$ node fetch-repos.js\n\n...\nForked repos found: 50\n^^ Geez!<\/code><\/pre>\n\n\n\nThis creates a file called repos.json<\/code> and you need to remove all the forks that you actually want to keep.<\/p>\n\n\n\nIt is worth reiterating from the repo’s documentation:<\/p>\n\n\n\n
The repositories that remain inside repos.json<\/code> will be deleted on the next command. It is an irreversible operation. Use with great caution!.<\/strong><\/p><\/blockquote>\n\n\n\nSee the last section on how I did a quick verification on each fork to see if I wanted to keep it or not.<\/p>\n\n\n\n
Deleting the unwanted forks<\/h2>\n\n\n\n See the warning above. Make sure you only keep the forks in repos.json<\/code> that you actually want to delete.<\/p>\n\n\n\nDelete the forks.<\/p>\n\n\n\n
$ node delete-repos.js<\/code><\/pre>\n\n\n\nAmazing in less than 2 seconds this deleted 68 forks I was no longer needing!<\/p>\n\n\n\n
Miscellaneous<\/h2>\n\n\n\n I wanted to visit the GitHub page for each of the forks. So I thought I would open all the tabs in bulk from the command line<\/p>\n\n\n\n
$ sed -e 's|\"andrejacobs|open \"https:\/\/github.com\/andrejacobs|' repos.json | sed -e 's\/\",\/\"\/' | awk '{$1=$1};1' | bash<\/code><\/pre>\n\n\n\nBreakdown<\/strong><\/p>\n\n\n\nReplace “andrejacobs with: open “https:\/\/github.com\/andrejacobs<\/p>\n\n\n\n
sed -e 's|\"andrejacobs|open \"https:\/\/github.com\/andrejacobs|'<\/code><\/pre>\n\n\n\nReplace “, with: “<\/p>\n\n\n\n
sed -e 's\/\",\/\"\/'<\/code><\/pre>\n\n\n\nTrim whitespace<\/p>\n\n\n\n
awk '{$1=$1};1'<\/code><\/pre>\n\n\n\nThis is by far not the most optimized or best way but it did open 50+ tabs in my browser.<\/p>\n\n\n\n
The process was pretty simple. I check what the fork is about and even visit the repo it was forked from to see if it still exists etc. and then made an informed decision if I wanted to keep my fork or not. Also now was a good time to start starring repos I cared about and NOT fork them.<\/p>\n","protected":false},"excerpt":{"rendered":"
Photo by Yancy Min on Unsplash At some point in my life I thought it would be a good idea to start forking git repos in GitHub instead of just starring them. I guess it started with a fear the repos might not exist in some point in the future and that I would like […]<\/p>\n
Read more →<\/a><\/p>\n","protected":false},"author":2,"featured_media":192,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[17],"tags":[33],"yoast_head":"\nDeleting unwanted forks from GitHub - Andr\u00e9 Jacobs<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n