Delete a GitHub Repository Safely with gh repo delete
You will remove one GitHub repository with the GitHub CLI, while making the repository name and the destructive confirmation explicit. This is a short operation, but spend a few minutes checking the target and any backup before you run the final command. Repository deletion is not a local Git operation and cannot be undone by a later git command.
The route
Jump straight to the step you need, or tick off Done means at the end.
This guide matches the installed GitHub CLI 2.87.3, released in February 2026. The local manual documents gh repo delete [<repository>] [flags], the --yes flag and the required delete_repo authorisation scope. The installed command also documents a safety rule that is easy to miss: when the repository argument is omitted, --yes is ignored and an interactive confirmation is still required.
Before you start
- Install and authenticate
ghfor the GitHub account or organisation that owns the repository. - Write down the exact repository name in
OWNER/REPOSITORYform. Replace the examples below; do not paste a name from an untrusted issue, shell variable or chat message without checking it. - Check that you have an independent copy of anything you may need. A clone is useful for Git objects, but it does not automatically preserve issues, pull requests, discussions, releases, settings or repository secrets.
No root access or sudo is needed. The operation changes the remote GitHub repository through the account's authorisation.
1. Confirm the installed command
Check the version and read the command's local help. This catches a different binary earlier in PATH and shows the behaviour of the version you are about to use.
$ gh --version
gh version 2.87.3 (2026-02-23)
$ gh repo delete --help
Checkpoint: the output should identify GitHub CLI 2.87.3, or you should stop and adjust this guide's version-specific expectations. The command syntax is gh repo delete [<repository>] [flags], and the only command-specific flag is --yes.
2. Check authentication before the destructive step
Ask gh which account and host it is using. Do not infer this from the repository's remote URL: GitHub CLI credentials and Git remotes can refer to different accounts.
$ gh auth status
Logged in to github.com account EXAMPLE_ACCOUNT (keyring)
✓ Logged in to github.com account EXAMPLE_ACCOUNT
✓ Git operations for github.com configured to use https protocol.
✓ Token scopes: ...
The exact status text varies. The important checkpoint is that the account is the intended one and that the token has the delete_repo scope. If it does not, refresh the scope deliberately:
$ gh auth refresh -s delete_repo
This may open a browser or ask for a one-time authorisation. A missing scope is an authorisation problem, not a reason to try a different repository name or add sudo.
3. Inspect the exact target
Use the fully qualified name for the final operation. First inspect it without changing anything:
$ gh repo view EXAMPLE_OWNER/EXAMPLE_REPOSITORY
Check the owner, repository name, visibility and description in the output. If the command reports that the repository cannot be found, stop. A typo, a different account, insufficient visibility or an organisation policy can all produce a lookup failure; none justifies guessing.
If you are working inside a local checkout, you can see which repository gh would use when no argument is supplied:
$ gh repo view
That convenience is useful for inspection, but avoid it for deletion. An invocation without an argument depends on the current directory and its Git remote, which makes an accidental directory change a dangerous distraction.
4. Make a last backup check
Before deletion, verify the copy you intend to keep. For Git data, a mirror is more complete than a working clone:
$ git clone --mirror https://github.com/EXAMPLE_OWNER/EXAMPLE_REPOSITORY.git EXAMPLE_REPOSITORY.git
$ git -C EXAMPLE_REPOSITORY.git fsck --full
Use an existing, trusted backup if one already meets your needs. Do not put a token into the URL or save credentials in a shell history merely to create this copy. Git data still does not cover GitHub-hosted metadata such as issues or repository settings.
Destructive action
Deletion removes the remote repository and its GitHub-hosted content. There is no gh repo delete undo command. If you cannot identify the target, confirm the account, or verify a suitable backup, stop here.
5. Delete by explicit name
When you have checked the target and accept the loss, pass the exact OWNER/REPOSITORY value and use --yes:
$ gh repo delete EXAMPLE_OWNER/EXAMPLE_REPOSITORY --yes
The explicit repository name matters. In GitHub CLI 2.87.3, --yes is honoured for an explicitly named repository. When no repository is supplied, this version ignores --yes and prompts anyway. That safety behaviour prevents a non-interactive command in the wrong checkout from deleting the checkout's current repository, but it is not a substitute for checking the name yourself.
A successful deletion normally returns to the shell without a substantial message. Treat the exit status as the first result:
$ printf 'exit status: %s\n' "$?"
exit status: 0
If the command fails, keep the repository name and error text. A non-zero status means you should not assume deletion happened; verify the remote state before retrying.
6. Verify the remote state
Ask GitHub CLI to view the repository again:
$ gh repo view EXAMPLE_OWNER/EXAMPLE_REPOSITORY
GraphQL: Could not resolve to a Repository with the name 'EXAMPLE_REPOSITORY'. (repository)
The exact error wording can change. The useful result is that the repository is no longer resolvable for the account. You can also test the Git endpoint without altering local files:
$ git ls-remote https://github.com/EXAMPLE_OWNER/EXAMPLE_REPOSITORY.git
fatal: repository 'https://github.com/EXAMPLE_OWNER/EXAMPLE_REPOSITORY.git/' not found
Do not interpret a local clone still being present as evidence that deletion failed. Deleting the GitHub repository does not erase your local directory. Preserve it as a source for rebuilding elsewhere if that is part of your recovery plan.
Common failure modes
- Missing
delete_reposcope: rungh auth refresh -s delete_repofor the intended account, then repeat the inspection. Scope refresh can require web authorisation. - Repository not found: compare the owner and name character by character, check
gh auth status, and confirm the host. Do not add a guessed organisation prefix. - Confirmation appears unexpectedly: the repository argument was omitted, so the installed CLI ignored
--yes. Cancel withCtrl-C, inspect the checkout, then use the explicit name only if it is correct. - Deletion succeeded but a local command fails: local Git data and GitHub's remote repository are separate. Keep the local clone, and create a new remote only after deciding how much metadata must be recreated.
Done means
- You checked the installed
ghversion and command help. gh auth statusshowed the intended account, withdelete_repoavailable or refreshed.gh repo view OWNER/REPOSITORYidentified the exact target before deletion.- You verified the backup boundary, including the GitHub metadata it does not contain.
- You ran
gh repo delete OWNER/REPOSITORY --yesonly after the final check. - The post-delete lookup no longer resolved, and you know the local clone is independent of the deleted remote.