Home Explore Blog CI



git

5th chunk of `Documentation/gitcredentials.adoc`
65ad53ed5d095e226862565197da9c89080b1ff4245843640000000100000c4a
 helper
[credential]
	helper = "foo --bar=baz"

# the arguments are parsed by the shell, so use shell
# quoting if necessary
[credential]
	helper = "foo --bar='whitespace arg'"

# store helper (discouraged) with custom location for the db file;
# use `--file ~/.git-secret.txt`, rather than `--file=~/.git-secret.txt`,
# to allow the shell to expand tilde to the home directory.
[credential]
	helper = "store --file ~/.git-secret.txt"

# you can also use an absolute path, which will not use the git wrapper
[credential]
	helper = "/path/to/my/helper --with-arguments"

# or you can specify your own shell snippet
[credential "https://example.com"]
	username = your_user
	helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"
----------------------------------------------------

Generally speaking, rule (3) above is the simplest for users to specify.
Authors of credential helpers should make an effort to assist their
users by naming their program "git-credential-$NAME", and putting it in
the `$PATH` or `$GIT_EXEC_PATH` during installation, which will allow a
user to enable it with `git config credential.helper $NAME`.

When a helper is executed, it will have one "operation" argument
appended to its command line, which is one of:

`get`::

	Return a matching credential, if any exists.

`store`::

	Store the credential, if applicable to the helper.

`erase`::

	Remove matching credentials, if any, from the helper's storage.

The details of the credential will be provided on the helper's stdin
stream. The exact format is the same as the input/output format of the
`git credential` plumbing command (see the section `INPUT/OUTPUT
FORMAT` in linkgit:git-credential[1] for a detailed specification).

For a `get` operation, the helper should produce a list of attributes on
stdout in the same format (see linkgit:git-credential[1] for common
attributes). A helper is free to produce a subset, or even no values at
all if it has nothing useful to provide. Any provided attributes will
overwrite those already known about by Git's credential subsystem.
Unrecognised attributes are silently discarded.

While it is possible to override all attributes, well behaving helpers
should refrain from doing so for any attribute other than username and
password.

If a helper outputs a `quit` attribute with a value of `true` or `1`,
no further helpers will be consulted, nor will the user be prompted
(if no credential has been provided, the operation will then fail).

Similarly, no more helpers will be consulted once both username and
password had been provided.

For a `store` or `erase` operation, the helper's output is ignored.

If a helper fails to perform the requested operation or needs to notify
the user of a potential issue, it may write to stderr.

If it does not support the requested operation (e.g., a read-only store
or generator), it should silently ignore the request.

If a helper receives any other operation, it should silently ignore the
request. This leaves room for future operations to be added (older
helpers will just ignore the new requests).

GIT
---
Part of the linkgit:git[1] suite

Title: Git Credential Helper Operations and Behavior
Summary
This section describes the behavior and operations of Git credential helpers, including the different types of operations (get, store, erase), the input and output formats, and the expected behavior of helpers in various scenarios, such as handling attributes, overriding values, and reporting errors.