Command referencegh auth logout
gh auth logout command (Linux & Windows / GitHub CLI)
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 / option | Meaning |
|---|---|
| -h, --hostname | Log out from a specific host. |
| -u, --user | Log 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.
Related commands
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh auth statusShow which GitHub accounts are logged in and whether credentials are valid for each host.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gitTrack source history and collaborate through distributed repositories.
- gh repo cloneClone a GitHub repository to your machine using your authenticated gh settings.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
- gh pr listList pull requests in a repository with state, author, and search filters.
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.