GH-AUTH-SETUP-GIT(1)

πŸ’… gh-auth-setup-git(1) β€” like, the git credential-helper glow-up

okay bestie, welcome to gh-auth-setup-git, straight out of the GitHub CLI manual (yes, that's the gh-auth-setup-git(1) girlie β€” she's in the GitHub CLI manual section, hi πŸ‘‹). She's a tiny command with one job and she does it flawlessly.


✨ NAME ✨

gh-auth-setup-git β€” set up git with the GitHub CLI. that's it, that's the whole name, and honestly? iconic. πŸŽ€


🌸 SYNOPSIS 🌸

gh auth setup-git [flags]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: this command configures git to use the GitHub CLI as a credential helper. and if you're sitting there like "girl what is a credential helper", no worries, there's a whole doc for that over at:

⟨https://git-scm.com/docs/gitcredentials⟩

now, by default, the GitHub CLI sets itself as the credential helper for all authenticated hosts. and if there are, like, no authenticated hosts at all? the command fails with an error. she's not gonna fake it for you, ngl 😭

alternatively β€” and this is the part where it gets cute β€” you can use the --hostname flag to specify a single host to be configured. and if that host is not authenticated with? yep, the command fails with an error. same energy, different scope. πŸ’…


πŸŽ€ OPTIONS πŸŽ€

  • -f, --force <--hostname> β€” forces setup even if the host isn't known. ⚠️ this one must be used in conjunction with --hostname, like they're a package deal, fr fr.
  • -h, --hostname <string> β€” the hostname to configure git for. one host, hand-picked, main character energy. πŸ‘‘

⭐ EXIT CODES ⭐

keep these in your notes app, bestie:

  • 0: successful execution ✨
  • 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 literally what it says 🫢

🌈 EXAMPLE 🌈

# Configure git to use GitHub CLI as the credential helper for all authenticated hosts
$ gh auth setup-git

# Configure git to use GitHub CLI as the credential helper for enterprise.internal host
$ gh auth setup-git --hostname enterprise.internal

see? two lines, both slaying, one for everybody and one for enterprise.internal specifically. no cap. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

gh-auth(1) β€” go read that one next, iykyk πŸ’œ


<div align="center">

~ and that's the vibe check ~ this page is brought to you by GitHub CLI v2.102.0, dated Oct 2026 β€” mwah, love u, go configure those credential helpers bestie πŸ§šπŸ’–

</div>

πŸ“¦ where this page comes from