Git Reference ยท Configuration Options
credential.* settings
Reference for credential.* settings: credential.helper, per-URL helpers, credential.useHttpPath, username and interactive, plus how git credential fill works.
When Git talks to an HTTP(S) server that wants a password or token, it asks a credential helper. A helper is a small program that can look up a stored secret, remember one for a while, or print one fresh. The credential.* settings choose the helper, restrict it to certain URLs and control whether the URL path takes part in matching.
Git never stores passwords itself. Without a helper it prompts in the terminal every time.
git config --global credential.helper cache # in memory, 15 minutes git config --global credential.helper "cache --timeout=3600" git config --global credential.helper store # plain text in ~/.git-credentials git config --global credential.https://github.com.helper manager git config --global credential.useHttpPath true
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config credential.helper <helper> git config credential.<url>.helper <helper> git config credential.<url>.username <name> git config credential.useHttpPath (true | false) git config credential.interactive (auto | never | always) git config credential.sanitizePrompt (true | false) git credential (fill | approve | reject)
| Name | Description |
|---|---|
credential.helper |
Helper to ask. Repeatable: Git tries each in order until one returns a password. A name such as cache runs git-credential-cache; a value starting with ! is a shell snippet; an absolute path is run as given. |
credential.<url>.helper |
Same, but only for matching URLs. The URL can be a host (https://github.com), a host with user, or a path prefix. |
credential.<url>.username |
Pre-fill the user name so only the password is asked. |
credential.useHttpPath |
Include the repository path when matching, so different repositories on one host can have different credentials. Default false. |
credential.interactive |
never stops Git prompting (useful in CI); always prompts even if a helper answered. |
credential.sanitizePrompt |
Percent-encode control characters in URLs shown in prompts (default true). |
The protocol: a helper is called with get, store or erase as its last argument and talks in key=value lines ending with an empty line. git credential fill|approve|reject lets you test one by hand, as the first example does.
Errors: with no helper and no terminal Git fails with fatal: could not read Username for '...': terminal prompts disabled; wrong credentials end with fatal: Authentication failed.
Usage notes
- Pick the right helper per OS:
manager(Git Credential Manager) on Windows and macOS,osxkeychainon macOS,libsecreton Linux desktops,cachefor short-lived sessions. storewrites plain text. Anyone who can read~/.git-credentialscan use the token; prefer an OS keychain, and use short-lived or scoped tokens.- Empty value resets the list.
credential.helper =(empty) clears helpers inherited from system or global config, so a repository can use only its own. - Use tokens, not passwords. Hosting services have dropped password authentication over HTTPS; the token goes into the password field.
useHttpPathmatters when one account per repository is needed on the same host; leave it off otherwise so a single login works for every repository.- Rotating a token: run
git credential reject(or remove the keychain entry) so the old value is not reused. - SSH remotes (
git@host:path) do not use credential helpers; they use keys and the SSH agent.