gh auth logout
gh auth logout [flags]
Remove authentication for a GitHub account.
By default, this command revokes the selected account's GitHub CLI OAuth token and removes its saved authentication locally. Copies of the same token used elsewhere stop working. Independently issued tokens are not revoked.
Other token types and unrecognized token formats are removed locally, with a warning that they were not revoked.
After local logout, saved HTTPS credentials for the host are also removed from Git credential helpers. If cleanup fails, the command prints a warning but still succeeds.
If revocation fails, including when it cannot be confirmed, local credentials are kept so you can retry. The command exits with an error.
If a refreshable OAuth token is not found, this command refreshes it once, saves the replacement credentials, and retries revocation. If saving fails, it attempts to revoke the replacement and returns an error requiring you to sign in again.
Use --no-revoke for local-only logout, without a network request.
This still prints a warning that the token was not revoked.
Options
-h,--hostname <string>- The hostname of the GitHub instance to log out of
-
--no-revoke - Remove local credentials without revoking the GitHub CLI OAuth token
-u,--user <string>- The account to log out of
Examples
# Select what host and account to log out of via a prompt
$ gh auth logout
# Log out of a specific host and specific account
$ gh auth logout --hostname enterprise.internal --user monalisa
# Remove local credentials without revoking the token
$ gh auth logout --no-revoke