Home / Alt manpages / gh-label-delete(1)

  • gh-label-delete(1)
  • User command
  • linux

Delete a GitHub Repository Label Safely with gh

You will remove one label from a chosen GitHub repository with the GitHub CLI, while keeping the repository and label name visible before the destructive step. Allow about five minutes. You need gh, an authenticated GitHub CLI session with permission to manage labels, and the repository name in OWNER/REPO form.

This guide uses GitHub CLI 2.87.3, installed here from the gh package. The command is gh label delete. It changes a remote repository, so do not run the final example until the target is confirmed.

1. Check the installed command

Confirm which executable will run and inspect its built-in help:

$ command -v gh
/home/linuxbrew/.linuxbrew/bin/gh
$ gh --version
gh version 2.87.3 (2026-02-23)
$ gh label delete --help
Delete a label from a repository

The local manual documents one required argument, <name>, and one command-specific option, --yes. The parent gh label command supplies -R and --repo for selecting a different repository.

2. Identify the exact repository and label

Write down both values before constructing the deletion command. The repository selector accepts [HOST/]OWNER/REPO; for GitHub.com, OWNER/REPO is normally enough. The label name is case-sensitive for practical use, and spaces are part of the name, so quote it in the shell.

$ repo='OWNER/REPO'
$ label='label-to-remove'
$ printf 'Repository: %s\nLabel: %s\n' "$repo" "$label"
Repository: OWNER/REPO
Label: label-to-remove

Replace both placeholder values. Do not paste a repository from a browser tab merely because its name looks familiar. Check the owner, repository, host if one is present, and label spelling. A label deletion is a remote state change and there is no confirmation option that tells GitHub to keep a backup.

3. Check the target before deleting

Use the label listing command to inspect the selected repository. This is a read-only check and can show the label's spelling, description and colour:

$ gh label list --repo "$repo" --search "$label"
NAME               DESCRIPTION       COLOR
label-to-remove     Old workflow      B60205

The exact columns and matching results depend on the repository and installed CLI version. If the expected label is not shown, stop and correct the repository or search value. A successful listing does not prove that a later deletion command will succeed, because permissions and repository state can change.

Checkpoint

Proceed only when the displayed repository and label are the ones you intend to change. If you cannot identify the target unambiguously, do not use --yes.

4. Delete interactively first

Run the command with the repository selected and leave out --yes for a human confirmation:

$ gh label delete "$label" --repo "$repo"
? Delete label "label-to-remove" from OWNER/REPO? Yes

The prompt text can vary slightly by CLI release. Read it before accepting. If you answer no, the command should leave the label in place. This is the safer form when typing the command manually.

On a terminal, pressing the interrupt key, usually Ctrl-C, is also a way to abandon the prompt before confirming. It is not a recovery mechanism after confirmation.

5. Use --yes only in a reviewed script

--yes confirms deletion without prompting. It is useful for a carefully reviewed maintenance script, but it removes the last interactive pause:

$ gh label delete "$label" --repo "$repo" --yes
$ printf 'exit status: %s\n' "$?"
exit status: 0

Do not place an unreviewed variable or broad loop in front of this option. Keep the repository and label values explicit where possible, and make the command fail rather than silently targeting a default repository. There is no elevated-privilege requirement on the Linux machine: sudo does not grant GitHub permission and should not be added. The relevant permission comes from the authenticated GitHub account or token.

6. Verify the result

After deletion, query the same repository again. A missing exact label is the useful result:

$ gh label list --repo "$repo" --search "$label"
NAME               DESCRIPTION       COLOR
another-label       Other work        0E8A16

The search command may return similarly named labels, so inspect the names rather than treating an empty-looking description as proof. If the command reports an API, authentication, repository or permission error, preserve the error text and fix that problem before retrying. Do not repeatedly add --yes to a command whose target is still uncertain.

Common traps and recovery

Omitting the label name is a local syntax error. The installed command reports cannot delete label: name argument required and exits without attempting deletion. Supplying a label name but no --yes in a non-interactive shell is different: the command reports that --yes is required when not running interactively. This prevents a silent destructive action in a pipeline, but it does not validate the target for you.

The short repository option is -R, not a shell option for running as root:

$ gh label delete "$label" -R "$repo"
? Delete label "label-to-remove" from OWNER/REPO? Yes

Do not use both -R and --repo with conflicting values. If you deleted the wrong label, stop and record the repository, name, description and colour from any review or audit data you have. Recovery is a deliberate recreation and reapplication exercise, not a second delete command; use the GitHub web interface or the separate label creation workflow only after checking the intended replacement details.

Done means

  • The installed gh version and command help were checked.
  • The exact repository and label were reviewed before deletion.
  • The interactive command was used for manual work, or --yes was reserved for a reviewed automation path.
  • The command returned success and a follow-up label listing confirmed the expected state.
  • No sudo, broad loop or unreviewed variable was used to widen the change.