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

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

Remove a GitHub CLI Extension Without Losing the Reinstall Path

You will remove one locally installed GitHub CLI extension, confirm that it has gone, and keep enough information to reinstall it later. Allow about five minutes. You need GitHub CLI (gh) and the name of an extension already installed for your user account. This operation 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 version 2.45.0-1ubuntu0.3+esm3. The installed manual page 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. The list is local to the current user, so run it 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, such as example in this output. Keep the repository name or URL as well if you may reinstall it. GitHub CLI extensions are third-party commands, not part of the core gh package, 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 the extension directory.

3. Remove one extension

Removal is destructive to the local installed copy. It does not delete the extension's GitHub repository, its releases, or a separate local source directory used 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

When standard output is 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 may be silent. The exit status is the reliable signal:

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

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 intended to remove.

4. Verify that the command disappeared

List extensions again and, if the extension 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 is useful only as a check for the extension itself. A name can resemble a built-in gh command, and removing an extension does not remove a core command with the same or a similar 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

This assumes the first column is the command name, as 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 the extension 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 that repository provides. If you had installed a pinned version, retain the original pin and pass it again with the documented --pin option. If it was a local development extension, reinstall from its source directory:

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

A local install is managed as a link or equivalent pointer to the executable in that source tree. Removing the managed installation is therefore 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 useful checks.

Common traps

  • Using the repository name incorrectly: the command accepts one extension name. example and gh-example are normalised to the same installed extension; do not pass owner/gh-example to the removal command 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 gh extension, not the Debian or Ubuntu gh package. To remove the core CLI, use your normal package-management process and a separate plan.
  • 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 extension publisher's repository remains untouched. Conversely, a remote repository being archived or deleted does not restore your local copy.

Done means

  • You checked the installed gh version and used the documented one-name command.
  • You recorded the extension's short name and repository or local source path before removal.
  • gh extension remove NAME returned status 0.
  • gh extension list no longer shows the extension.
  • You know the reinstall command, including any original pin, if the removal needs reversing.