2 .\" Title: git-credential
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.46.2.673.ga116aba5d5
10 .TH "GIT\-CREDENTIAL" "1" "2024-09-25" "Git 2\&.46\&.2\&.673\&.ga116ab" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-credential \- Retrieve and store user credentials
35 \*(Aqgit credential\*(Aq (fill|approve|reject|capability)
39 Git has an internal interface for storing and retrieving credentials from system\-specific helpers, as well as prompting the user for usernames and passwords\&. The git\-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for credentials in the same manner as Git\&. The design of this scriptable interface models the internal C API; see credential\&.h for more background on the concepts\&.
41 git\-credential takes an "action" option on the command\-line (one of \fBfill\fR, \fBapprove\fR, or \fBreject\fR) and reads a credential description on stdin (see INPUT/OUTPUT FORMAT)\&.
43 If the action is \fBfill\fR, git\-credential will attempt to add "username" and "password" attributes to the description by reading config files, by contacting any configured credential helpers, or by prompting the user\&. The username and password attributes of the credential description are then printed to stdout together with the attributes already provided\&.
45 If the action is \fBapprove\fR, git\-credential will send the description to any configured credential helpers, which may store the credential for later use\&.
47 If the action is \fBreject\fR, git\-credential will send the description to any configured credential helpers, which may erase any stored credentials matching the description\&.
49 If the action is \fBcapability\fR, git\-credential will announce any capabilities it supports to standard output\&.
51 If the action is \fBapprove\fR or \fBreject\fR, no output should be emitted\&.
52 .SH "TYPICAL USE OF GIT CREDENTIAL"
54 An application using git\-credential will typically use \fBgit credential\fR following these steps:
64 Generate a credential description based on the context\&.
66 For example, if we want a password for
67 \fBhttps://example\&.com/foo\&.git\fR, we might generate the following credential description (don\(cqt forget the blank line at the end; it tells
69 that the application finished feeding all the information it has):
92 Ask git\-credential to give us a username and password for this description\&. This is done by running
93 \fBgit credential fill\fR, feeding the description from step (1) to its standard input\&. The complete credential description (including the credential per se, i\&.e\&. the login and password) will be produced on standard output, like:
108 In most cases, this means the attributes given in the input will be repeated in the output, but Git may also modify the credential description, for example by removing the
110 attribute when the protocol is HTTP(s) and
111 \fBcredential\&.useHttpPath\fR
116 knew about the password, this step may not have involved the user actually typing this password (the user may have typed a password to unlock the keychain instead, or no user interaction was done if the keychain was already unlocked) before it returned
117 \fBpassword=secr3t\fR\&.
128 Use the credential (e\&.g\&., access the URL with the username and password from step (2)), and see if it\(cqs accepted\&.
139 Report on the success or failure of the password\&. If the credential allowed the operation to complete successfully, then it can be marked with an "approve" action to tell
141 to reuse it in its next invocation\&. If the credential was rejected during the operation, use the "reject" action so that
143 will ask for a new password in its next invocation\&. In either case,
145 should be fed with the credential description obtained from step (2) (which also contains the fields provided in step (1))\&.
147 .SH "INPUT/OUTPUT FORMAT"
149 \fBgit credential\fR reads and/or writes (depending on the action used) credential information in its standard input/output\&. This information can correspond either to keys for which \fBgit credential\fR will obtain the login information (e\&.g\&. host, protocol, path), or to the actual credential data to be obtained (username/password)\&.
151 The credential is split into a set of named attributes, with one attribute per line\&. Each attribute is specified by a key\-value pair, separated by an \fB=\fR (equals) sign, followed by a newline\&.
153 The key may contain any bytes except \fB=\fR, newline, or NUL\&. The value may contain any bytes except newline or NUL\&. A line, including the trailing newline, may not exceed 65535 bytes in order to allow implementations to parse efficiently\&.
155 Attributes with keys that end with C\-style array brackets \fB[]\fR can have multiple values\&. Each instance of a multi\-valued attribute forms an ordered list of values \- the order of the repeated attributes defines the order of the values\&. An empty multi\-valued attribute (\fBkey[]=\en\fR) acts to clear any previous entries and reset the list\&.
157 In all cases, all bytes are treated as\-is (i\&.e\&., there is no quoting, and one cannot transmit a value with newline or NUL in it)\&. The list of attributes is terminated by a blank line or end\-of\-file\&.
159 Git understands the following attributes:
163 The protocol over which the credential will be used (e\&.g\&.,
169 The remote hostname for a network credential\&. This includes the port number if one was specified (e\&.g\&., "example\&.com:8088")\&.
174 The path with which the credential will be used\&. E\&.g\&., for accessing a remote https repository, this will be the repository\(cqs path on the server\&.
179 The credential\(cqs username, if we already have one (e\&.g\&., from a URL, the configuration, the user, or from a previously run helper)\&.
184 The credential\(cqs password, if we are asking it to be stored\&.
187 \fBpassword_expiry_utc\fR
189 Generated passwords such as an OAuth access token may have an expiry date\&. When reading credentials from helpers,
190 \fBgit credential fill\fR
191 ignores expired passwords\&. Represented as Unix time UTC, seconds since 1970\&.
194 \fBoauth_refresh_token\fR
196 An OAuth refresh token may accompany a password that is an OAuth access token\&. Helpers must treat this attribute as confidential like the password attribute\&. Git itself has no special behaviour for this attribute\&.
201 When this special attribute is read by
202 \fBgit credential\fR, the value is parsed as a URL and treated as if its constituent parts were read (e\&.g\&.,
203 \fBurl=https://example\&.com\fR
207 \fBhost=example\&.com\fR
208 had been provided)\&. This can help callers avoid parsing URLs themselves\&.
210 Note that specifying a protocol is mandatory and if the URL doesn\(cqt specify a hostname (e\&.g\&., "cert:///path/to/file") the credential will contain a hostname attribute whose value is an empty string\&.
212 Components which are missing from the URL (e\&.g\&., there is no username in the example above) will be left unset\&.
217 This indicates that the authentication scheme in question should be used\&. Common values for HTTP and HTTPS include
220 \fBdigest\fR, although the latter is insecure and should not be used\&. If
222 is used, this may be set to an arbitrary string suitable for the protocol in question (usually HTTP)\&.
224 This value should not be sent unless the appropriate capability (see below) is provided on input\&.
229 The pre\-encoded credential, suitable for the protocol in question (usually HTTP)\&. If this key is sent,
235 are not used\&. For HTTP, Git concatenates the
237 value and this value with a single space to determine the
241 This value should not be sent unless the appropriate capability (see below) is provided on input\&.
246 This boolean value indicates, if true, that the value in the
248 field should not be saved by the credential helper because its usefulness is limited in time\&. For example, an HTTP Digest
250 value is computed using a nonce and reusing it will not result in successful authentication\&. This may also be used for situations with short duration (e\&.g\&., 24\-hour) credentials\&. The default value is false\&.
252 The credential helper will still be invoked with
256 so that it can determine whether the operation was successful\&.
258 This value should not be sent unless the appropriate capability (see below) is provided on input\&.
263 This value provides an opaque state that will be passed back to this helper if it is called again\&. Each different credential helper may specify this once\&. The value should include a prefix unique to the credential helper and should ignore values that don\(cqt match its prefix\&.
265 This value should not be sent unless the appropriate capability (see below) is provided on input\&.
270 This is a boolean value, which, if enabled, indicates that this authentication is a non\-final part of a multistage authentication step\&. This is common in protocols such as NTLM and Kerberos, where two rounds of client authentication are required, and setting this flag allows the credential helper to implement the multistage authentication step\&. This flag should only be sent if a further stage is required; that is, if another round of authentication is expected\&.
272 This value should not be sent unless the appropriate capability (see below) is provided on input\&. This attribute is
274 from a credential helper to pass information to Git (or other programs invoking
275 \fBgit credential\fR)\&.
280 When an HTTP response is received by Git that includes one or more
281 \fIWWW\-Authenticate\fR
282 authentication headers, these will be passed by Git to credential helpers\&.
285 \fIWWW\-Authenticate\fR
286 header value is passed as a multi\-valued attribute
287 \fIwwwauth[]\fR, where the order of the attributes is the same as they appear in the HTTP response\&. This attribute is
289 from Git to pass additional information to credential helpers\&.
294 This signals that Git, or the helper, as appropriate, supports the capability in question\&. This can be used to provide better, more specific data as part of the protocol\&. A
296 directive must precede any value depending on it and these directives
298 be the first item announced in the protocol\&.
300 There are two currently supported capabilities\&. The first is
301 \fBauthtype\fR, which indicates that the
303 \fBcredential\fR, and
305 values are understood\&. The second is
306 \fBstate\fR, which indicates that the
310 values are understood\&.
312 It is not obligatory to use the additional features just because the capability is supported, but they should not be provided without the capability\&.
315 Unrecognised attributes and capabilities are silently discarded\&.
316 .SH "CAPABILITY INPUT/OUTPUT FORMAT"
318 For \fBgit credential capability\fR, the format is slightly different\&. First, a \fBversion 0\fR announcement is made to indicate the current version of the protocol, and then each capability is announced with a line like \fBcapability authtype\fR\&. Credential helpers may also implement this format, again with the \fBcapability\fR argument\&. Additional lines may be added in the future; callers should ignore lines which they don\(cqt understand\&.
320 Because this is a new part of the credential helper protocol, older versions of Git, as well as some credential helpers, may not support it\&. If a non\-zero exit status is received, or if the first line doesn\(cqt start with the word \fBversion\fR and a space, callers should assume that no capabilities are supported\&.
322 The intention of this format is to differentiate it from the credential output in an unambiguous way\&. It is possible to use very simple credential helpers (e\&.g\&., inline shell scripts) which always produce identical output\&. Using a distinct format allows users to continue to use this syntax without having to worry about correctly implementing capability advertisements or accidentally confusing callers querying for capabilities\&.
325 Part of the \fBgit\fR(1) suite