GH-AUTH-SETUP-GIT(1) GitHub CLI manual GH-AUTH-SETUP-GIT(1)

# [NAME](#NAME)

gh-auth-setup-git - Setup git with GitHub CLI

# [SYNOPSIS](#SYNOPSIS)

**gh auth setup-git \[flags]**

# [DESCRIPTION](#DESCRIPTION)

This command configures **git** to use GitHub CLI as a credential helper. For more information on git credential helpers please reference:

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

By default, GitHub CLI will be set as the credential helper for all authenticated hosts. If there is no authenticated hosts the command fails with an error.

Alternatively, use the **--hostname** flag to specify a single host to be configured. If the host is not authenticated with, the command fails with an error.

# [OPTIONS](#OPTIONS)

[**-f**, **--force** **&lt;--hostname&gt;**](#f)

Force setup even if the host is not known. Must be used in conjunction with --hostname

[**-h**, **--hostname** **&lt;string&gt;**](#h)

The hostname to configure git for

# [EXIT CODES](#EXIT_CODES)

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.

# [EXAMPLE](#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 ALSO](#SEE_ALSO)

[**gh-auth(1)**](/man/os/gh/gh-auth.1)

Oct 2026

---

Document: gh-auth-setup-git(1) from gh 2.103.3-r0 (Chainguard OS)
Source: https://github.com/cli/cli
