Home / Alt manpages / gh-extension-remove(1)

  • gh-extension-remove(1)
  • User command
  • linux

Remove a GitHub CLI Extension Without Losing the Reinstall Path

Deleting a gh extension takes one command and no confirmation prompt, so the record-keeping happens before you run it, not after. Allow about five minutes. You need GitHub CLI (gh) and the name of an extension already installed for your user account. This does not need sudo.

1. Check the installed gh version

The local command is GitHub CLI 2.45.0 from package gh, installed here as Debian package 2.45.0-1ubuntu0.3+esm3. The installed manual gives the command shape but no option beyond the inherited help flag, so the exact command on your machine is the authority for version-specific details.

$ gh --version
gh version 2.45.0 (2026-02-23)
$ gh extension remove --help
Remove an installed extension

USAGE
  gh extension remove <name> [flags]

INHERITED FLAGS
  --help   Show help for command

There are no removal-specific switches in this version. In particular, do not add a guessed --force or --yes flag: the command takes exactly one name.

2. Record the extension before deleting it

List installed extensions first, as the same account that installed the extension:

$ gh extension list
gh-example	owner/gh-example	v1.2.3

Your columns and version text can differ. The useful value is the short extension name, example in this output. Keep the repository name or URL too, in case you reinstall it. These are third-party commands, not part of core gh, and GitHub advises reviewing their source and provenance.

Checkpoint

Write down the exact short name and repository reference before continuing. If gh extension list is empty, there is nothing for this command to remove. If it fails because this user has not configured GitHub CLI, fix that account-level setup first rather than guessing at the extension directory.

3. Remove one extension

Removal is destructive to the local installed copy. What it does not touch:

  • The extension's GitHub repository.
  • Its releases.
  • A separate local source directory you might use for development.

It removes the managed installation and its stored update state. The command normalises a name without the gh- prefix, so pass the short name shown by the list:

$ gh extension remove example

On a terminal, the installed command reports a success line similar to:

✓ Removed extension gh-example

In a pipe or other non-interactive output, a successful run can be silent, so the exit status is the reliable signal:

$ gh extension remove example
$ printf 'exit status: %s\n' "$?"
exit status: 0

Warning

Do not use sudo. Extensions are installed for the current user, and elevating the command can inspect or alter a different user's GitHub CLI data instead of the installation you meant to remove.

4. Verify that the command disappeared

List extensions again and, if the name did not collide with a core command, check the command dispatcher too:

$ gh extension list
$ gh extension exec example
no extension matched "example"
exit status: 1

The second command only tells you about the extension: a name can resemble a built-in gh command, and removing an extension does not remove a core command sharing its name. Treat an empty list as the primary check. For a script or automation job, make the check explicit without turning a missing extension into a failure:

$ if gh extension list | awk '{print $1}' | grep -Fxq 'gh-example'; then
>   echo 'extension still installed'
>   exit 1
> fi
$ echo 'extension removed'
extension removed

That assumes the first column is the command name, which it is in the normal list output. For a one-off manual check, reading the list is less fragile than building a script around display formatting.

5. Recover by reinstalling the recorded source

There is no undo subcommand. Reinstall from the repository reference you recorded in step 2:

$ gh extension install owner/gh-example

The install command may choose a release artefact or clone the repository, depending on what it provides. If you had pinned a version, pass the original pin again with --pin. If it was a local development extension, reinstall from its source directory instead:

$ gh extension install /path/to/gh-example

Recovery

A local install is managed as a link or equivalent pointer to the executable in that source tree. Removing the managed installation is not a substitute for deleting the source tree, and deleting that source tree separately can make recovery harder.

After reinstalling, confirm both presence and identity:

$ gh extension list
gh-example	owner/gh-example	v1.2.3
$ gh example --help

The extension's own help output is publisher-specific, so do not treat any particular wording as universal. A listed extension and a successful help invocation are the checks that matter.

Common traps

  • Passing the repository name instead of the short name. example and gh-example normalise to the same installed extension; do not pass owner/gh-example unless your local help and version explicitly accept it.
  • Expecting a confirmation prompt. This command has no documented confirmation flag or interactive safety question. Verify the name with gh extension list before running it.
  • Looking for a system-wide uninstall. This removes a user-scoped extension, not the Debian or Ubuntu gh package. Removing the core CLI is a separate process entirely.
  • Removing the wrong user's extension. sudo, a different login account, or a different GH_CONFIG_DIR can point GitHub CLI at another user's state. Check id -un and your shell environment if the list is unexpectedly empty.
  • Assuming the remote repository is gone. The publisher's repository stays untouched. Equally, a remote repository being archived or deleted does not restore your local copy.

Done means

  • Version checked: you confirmed the installed gh version and used the documented one-name command.
  • Details recorded: you noted the extension's short name and repository or local source path before removal.
  • Removal succeeded: gh extension remove NAME returned status 0.
  • Gone from the list: gh extension list no longer shows the extension.
  • Reinstall path known: you know the reinstall command, including any original pin, if you need to reverse this.