Skip to content

Instantly share code, notes, and snippets.

@ntamvl
Last active February 21, 2024 11:14
Show Gist options
  • Save ntamvl/52584701c0fefd24f42bf6f8e8bef446 to your computer and use it in GitHub Desktop.
Save ntamvl/52584701c0fefd24f42bf6f8e8bef446 to your computer and use it in GitHub Desktop.
Clean Up Unused GitHub Repositories! Delete all unused repositories and forgotten forks in 6 (semi)-automatic steps!

Clean Up Unused GitHub Repositories!

Delete all unused repositories and forgotten forks in 6 (semi)-automatic steps!

Ugh. Github forces me to type my password for every fork and repository I want to delete. That’s smart and all, but what if one wants to mass-delete a bunch of old, unused, forgotten, dirty little repositories that make his repository list look like a mess? well, that person follows this short guide:

[1.] Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click)

https://github.com/wildeyes?tab=repositories

[2.] Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall?hl=en to shorten them to a list.

[3.] Save that list to to a file somewhere. The list should be in the form of “ur_username/repo_name” per line, not a full URL!

[4.] Register a new personal access token with a delete_repo permission at this address

https://github.com/settings/tokens/new

[5.] Use the line appropriate for your operating system below, replacing UR_TOKEN with your access_token.

[6.] For OSX + Linux:

while read repo; do curl -X DELETE -H "Authorization: token UR_TOKEN" "https://api.github.com/repos/$repo"; done < repos.txt

[7.] For Windows: Run in powershell:

get-content D:\repolist.txt | ForEach-Object { Invoke-WebRequest -Uri https://api.github.com/repos/$_ -Method "DELETE" -Headers @{"Authorization"="token UR_TOKEN"} }

source: https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.mkna857dz

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