GH-AUTH-REFRESH(1)

πŸŽ€ gh-auth-refresh(1) β€” the GitHub CLI manual, bestie edition πŸŽ€

okay so picture this: it's a gh manual page, it's from the GitHub CLI manual, and it's literally about refreshing your stored auth credentials. yes we're doing this. sit down, grab a strawberry πŸ“, i got you.


✨ SYNOPSIS ✨

gh auth refresh [flags]

that's it. that's the whole vibe. flags optional, glow-up mandatory πŸ’…


πŸ’– DESCRIPTION πŸ’–

So what does this actually do? It expands or fixes the permission scopes for your stored credentials for the active account. That's the whole personality. πŸ”₯

The --scopes flag accepts a comma separated list of scopes you want your gh credentials to have. And here's the cute part: if no scopes are provided, the command maintains previously added scopes. it doesn't forget your progress, it's not that kind of friend 🫢

The --remove-scopes flag accepts a comma separated list of scopes you want to remove from your gh credentials. And ngl, scope removal is idempotent β€” do it once, do it five times, same result, she is consistent πŸ’… The minimum set of scopes (repo, read:org, and gist) cannot be removed. those three are the ride-or-die besties, they're not leaving the group chat, periodt.

The --reset-scopes flag resets the scopes for your gh credentials to the default set of scopes for your auth flow. full factory reset energy, main character rebirth moment ✨

Now this next one is important, listen up πŸ¦‹ β€” if you have multiple accounts in gh auth status and want to refresh the credentials for an inactive account, you will have to use gh auth switch to that account first before using this command, and then switch back when you are done. yes it's a whole little back-and-forth, a little field trip, but that's the rule, no cap.

For more information on OAuth scopes, see:

⟨https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps/⟩

(go read it, iykyk πŸ“š)


🌸 OPTIONS 🌸

  • -c, --clipboard β€” Copy one-time OAuth device code to clipboard. yes, clipboard, so you don't have to retype a cursed code with your own two hands 😭
  • -h, --hostname <string> β€” The GitHub host to use for authentication. pick your host, bestie πŸ‘‘
  • --insecure-storage β€” Save authentication credentials in plain text instead of credential store. ⚠️ like the name literally says insecure, so know what you're signing up for
  • -r, --remove-scopes <strings> β€” Authentication scopes to remove from gh. bye felicia πŸ‘‹
  • --reset-scopes β€” Reset authentication scopes to the default minimum set of scopes. back to basics, clean slate, iconic πŸ’œ
  • -s, --scopes <strings> β€” Additional authentication scopes for gh to have. more perks, more power, more scope πŸ’…

πŸ’€ EXIT CODES πŸ’€

the receipts of how it went:

  • 0: Successful execution πŸŽ‰ ate and left no crumbs
  • 1: Error πŸ™ˆ it's giving oops
  • 2: Command canceled πŸ’€ you hit Ctrl+C or something, it happens
  • 4: Authentication required πŸ” you gotta log in first, bestie
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

so like, don't assume this list is the final word for every command, check the help, i promise it's worth it 🧚


⭐ EXAMPLE ⭐

here's where it gets fun, copy these exact lines, i'm serious:

# Open a browser to add write:org and read:public_key scopes
$ gh auth refresh --scopes write:org,read:public_key

# Open a browser to ensure your authentication credentials have the correct minimum scopes
$ gh auth refresh

# Open a browser to idempotently remove the delete_repo scope
$ gh auth refresh --remove-scopes delete_repo

# Open a browser to re-authenticate with the default minimum scopes
$ gh auth refresh --reset-scopes

# Open a browser to re-authenticate and copy one-time OAuth code to clipboard
$ gh auth refresh --clipboard

every single one of these opens a browser btw, that's just the whole thing, she's a browser-opening queen 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

  • gh-auth(1) β€” the parent, the origin story, the blueprint πŸ‘‘

and that's the page!! no notes, obsessed πŸ’–

GitHub CLI v2.102.0 Β· Oct 2026 β€” mwah, thanks for reading, go refresh those scopes bestie πŸŽ€πŸ’œ

πŸ“¦ where this page comes from