Skip to main content

Command referencegh auth logout

gh auth logout command (Linux & Windows / GitHub CLI)

Linux & WindowsGitHub CLIgitbeginner

What it does

Remove GitHub CLI authentication for a host or account from the local machine. When people search for gh auth logout, they usually want practical GitHub CLI flags, safe examples, and how this subcommand fits everyday PR and repo workflows on Linux, Windows, and macOS. Syntax, options, and copyable examples are below.

Remove GitHub CLI authentication for a host or account from the local machine.

Syntax

gh auth logout [flags]

Common options

Flag / optionMeaning
-h, --hostnameLog out from a specific host.
-u, --userLog out a specific account when multiple are stored.

Practical examples

Log out default host

gh auth logout

Removes stored credentials for the selected account/host.

Enterprise logout

gh auth logout -h github.example.com

Clears credentials for an Enterprise Server host.

Common mistakes

  • Logging out on a shared CI image and breaking later pipeline steps.
  • Expecting logout to revoke the token on GitHub itself — it mainly clears local storage.

FAQ

What does gh auth logout do in GitHub CLI?

Remove GitHub CLI authentication for a host or account from the local machine.

Does gh auth logout work on Windows and Linux?

Yes. The GitHub CLI (`gh`) runs on Linux, Windows, and macOS with the same subcommand syntax after you authenticate with `gh auth login`.

What is a practical gh auth logout example?

Try `gh auth logout` — Removes stored credentials for the selected account/host.

Do I need a token in the command line for gh auth logout?

Prefer `gh auth login` so credentials stay in the system keyring or secure storage. Avoid pasting personal access tokens into shell history.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.