Skip to content

Instantly share code, notes, and snippets.

@mrkpatchaa
Last active March 8, 2026 20:27
Show Gist options
  • Select an option

  • Save mrkpatchaa/63720cbf744a2bf59a3e9cfe73fc33b0 to your computer and use it in GitHub Desktop.

Select an option

Save mrkpatchaa/63720cbf744a2bf59a3e9cfe73fc33b0 to your computer and use it in GitHub Desktop.
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. 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

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. 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.

  5. Register a new personal access token with a 'delete_repo perm' https://github.com/settings/tokens/new

  6. 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"} }

Caution

I have only tested this script on Linux.

Have fun :)

@itsjavi
Copy link

itsjavi commented Feb 23, 2026

For deleting organization team repos

  1. Generate a personal access token with 'delete_repo' permission: https://github.com/settings/tokens/new
  2. Open the teams repositories view and run following in the browsers console
let repos = ''
const el = document.querySelectorAll('#org-team-repositories > ul > li > div:nth-child(1) > div > div:nth-child(2) > a > span').forEach(e => {repos = repos + `"${e.innerText}"\n`})
console.log(repos)
  1. Copy paste the output to @aug2uag shell script and run it (fixed extra space typo in it):
#!/bin/bash

repos=(
	"username/repo1"
	"username/repo2"
	"username/repo3"
)

for i in "${repos[@]}"
do
   : 
   echo 'Delete' "$i";
   curl -XDELETE -H 'Authorization: token XXXX' "https://api.github.com/repos/$i";
done

Best solution, without third-party tools.

This works for me in 2026 for personal repositories (paginated):

let repos = ''
const el = document.querySelectorAll('#user-repositories-list [itemprop~=codeRepository]')
    .forEach(e => {repos = repos + `"${e.innerText}"\n`})
console.log(repos)

@christianpaez
Copy link

Still useful, thanks a lot!

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