Delete All GitHub Forks at Once
I went to clean up my GitHub profile and found it buried under a few hundred forks I'd made over the years to read someone else's code. None had commits I cared about. Deleting them one at a time through the web UI, each behind a "type the repository name to confirm" gate, was not going to happen. The gh CLI clears them in a single line, once you get past one non-obvious permission.
TL;DR
To delete all your GitHub forks at once, grant the gh CLI the delete_repo scope, list your forks with gh repo list --fork, and pipe each one to gh repo delete --yes. It is irreversible, so list them first and read the output before you pipe it into the delete.
Grant the delete scope first
gh will not delete a repository without the delete_repo OAuth scope, and it does not request that scope by default. You only need to add it once:
gh auth refresh -h github.com -s delete_repoSkip this and every delete fails with a permissions error that does not mention scopes, which is the part that wastes ten minutes.
List your forks before you touch anything
Always look before you delete. gh repo list with --fork returns only the repositories that are forks:
gh repo list --fork --limit 1000 --json nameWithOwner -q '.[].nameWithOwner'--limit defaults to 30, so set it higher than your fork count or the command silently skips the rest. Read the list it prints. Everything on it is about to be gone.
Delete them all
Pipe that list into gh repo delete. The --yes flag skips the per-repository confirmation (you already confirmed by running the pipeline):
gh repo list --fork --limit 1000 --json nameWithOwner -q '.[].nameWithOwner' \
| xargs -I{} gh repo delete {} --yesCaution
This is permanent. A deleted fork is gone, along with its issues, stars, and any branches on it. If a fork holds work you never pushed anywhere else, it is not coming back. When unsure, drop --yes so each delete prompts you.
Keep a few
If a handful are worth keeping, filter them out before the delete. A grep -v is enough:
gh repo list --fork --limit 1000 --json nameWithOwner -q '.[].nameWithOwner' \
| grep -v -e your-user/dotfiles -e your-user/keep-this \
| xargs -I{} gh repo delete {} --yesThe web UI makes bulk deletion deliberately painful because deletion is dangerous. The CLI trusts you instead, so the safety has to come from you: list first, read the output, and only then pipe it forward.
FAQ
How do I delete all my GitHub forks at once?
Grant the gh CLI the delete_repo scope (gh auth refresh -h github.com -s delete_repo), list your forks with gh repo list --fork --limit 1000 --json nameWithOwner -q '.[].nameWithOwner', and pipe that into xargs -I{} gh repo delete {} --yes.
Why does gh repo delete fail with a permissions error?
The gh CLI does not request the delete_repo OAuth scope by default. Run gh auth refresh -h github.com -s delete_repo once to add it, then retry the delete.
Does the --limit flag matter?
Yes. gh repo list returns 30 results by default, so if you have more forks than that, set --limit above your total or the command will quietly leave the rest behind.
Can I undo deleting a fork?
No. Deleting a fork is permanent and takes its issues, stars, and unpushed branches with it. List the forks first, and drop --yes if you want a confirmation prompt per repository.
