GH-AUTH-SWITCH(1)

πŸ’… GH-AUTH-SWITCH β€” switching your whole vibe (and account)

Hey bestie, welcome to gh-auth-switch, the GitHub CLI manual page for switching your active GitHub account ✨ this lives in the GitHub CLI manual, and honestly? It's giving "one command, zero drama."


✨ SYNOPSIS ✨

gh auth switch [flags]

That's it. That's the whole thing. Periodt. πŸŽ€


🌸 DESCRIPTION 🌸

Okay so here's the tea: this command switches the active account for a GitHub host.

Lowkey what that means is β€” it changes the auth configuration that's gonna get used whenever you run commands targeting that specific GitHub host. So like, the account you switch to? That's the one showing up to the party. πŸ’…

Now, the details matter, so listen up:

  • If the host you name has two accounts, the active account gets switched automatically. No input needed, it just goes. Slay.
  • If there are more than two accounts, disambiguation is literally required β€” either through the --user flag or via an interactive prompt. You gotta tell it who you mean, iykyk.

And if you ever wanna see the full list of authenticated accounts? Just run gh auth status. That's the vibe check for your logins. πŸ”


πŸ¦‹ OPTIONS πŸ¦‹

  • -h, --hostname <string> β€” the hostname of the GitHub instance you're switching the account for 🏠
  • -u, --user <string> β€” the account you're switching to πŸ‘‘

πŸ’€ EXIT CODES πŸ’€

  • 0 β€” successful execution, we ate πŸ“
  • 1 β€” error 😭
  • 2 β€” command canceled πŸ™ˆ
  • 4 β€” authentication required πŸ”
NOTE: specific commands may have additional exit codes. Refer to the command's help for more information. Don't come for me, that's just how it is. 🫢

🌈 EXAMPLE 🌈

# Select what host and account to switch to via a prompt
$ gh auth switch

# Switch the active account on a specific host to a specific user
$ gh auth switch --hostname enterprise.internal --user monalisa

First one's the prompt life β€” you pick the host and the account interactively 🧚 Second one's for when you already know exactly what you want, so you just say --hostname enterprise.internal and --user monalisa and dip. Iconic. ⭐


πŸ‘‘ SEE ALSO πŸ‘‘

  • gh-auth(1) β€” the main character of the auth universe

πŸ’œ aaaand that's the page! brought to you by GitHub CLI v2.102.0, dated Oct 2026 β€” no cap, those are the real numbers. mwah, go switch some accounts bestie πŸ’–βœ¨
πŸ“¦ where this page comes from