2 .\" Title: git-credential
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.42.0.424.gceadf0f3cf
10 .TH "GIT\-CREDENTIAL" "1" "2023\-10\-20" "Git 2\&.42\&.0\&.424\&.gceadf0" "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)
40 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\&.
42 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)\&.
44 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\&.
46 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\&.
48 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\&.
50 If the action is \fBapprove\fR or \fBreject\fR, no output should be emitted\&.
51 .SH "TYPICAL USE OF GIT CREDENTIAL"
53 An application using git\-credential will typically use \fBgit credential\fR following these steps:
63 Generate a credential description based on the context\&.
65 For example, if we want a password for
66 \fBhttps://example\&.com/foo\&.git\fR, we might generate the following credential description (don\(cqt forget the blank line at the end; it tells
68 that the application finished feeding all the information it has):
91 Ask git\-credential to give us a username and password for this description\&. This is done by running
92 \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:
107 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
109 attribute when the protocol is HTTP(s) and
110 \fBcredential\&.useHttpPath\fR
115 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
116 \fBpassword=secr3t\fR\&.
127 Use the credential (e\&.g\&., access the URL with the username and password from step (2)), and see if it\(cqs accepted\&.
138 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
140 to reuse it in its next invocation\&. If the credential was rejected during the operation, use the "reject" action so that
142 will ask for a new password in its next invocation\&. In either case,
144 should be fed with the credential description obtained from step (2) (which also contain the ones provided in step (1))\&.
146 .SH "INPUT/OUTPUT FORMAT"
148 \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)\&.
150 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\&.
152 The key may contain any bytes except \fB=\fR, newline, or NUL\&. The value may contain any bytes except newline or NUL\&.
154 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\&.
156 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\&.
158 Git understands the following attributes:
162 The protocol over which the credential will be used (e\&.g\&.,
168 The remote hostname for a network credential\&. This includes the port number if one was specified (e\&.g\&., "example\&.com:8088")\&.
173 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\&.
178 The credential\(cqs username, if we already have one (e\&.g\&., from a URL, the configuration, the user, or from a previously run helper)\&.
183 The credential\(cqs password, if we are asking it to be stored\&.
186 \fBpassword_expiry_utc\fR
188 Generated passwords such as an OAuth access token may have an expiry date\&. When reading credentials from helpers,
189 \fBgit credential fill\fR
190 ignores expired passwords\&. Represented as Unix time UTC, seconds since 1970\&.
193 \fBoauth_refresh_token\fR
195 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\&.
200 When this special attribute is read by
201 \fBgit credential\fR, the value is parsed as a URL and treated as if its constituent parts were read (e\&.g\&.,
202 \fBurl=https://example\&.com\fR
206 \fBhost=example\&.com\fR
207 had been provided)\&. This can help callers avoid parsing URLs themselves\&.
209 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\&.
211 Components which are missing from the URL (e\&.g\&., there is no username in the example above) will be left unset\&.
216 When an HTTP response is received by Git that includes one or more
217 \fIWWW\-Authenticate\fR
218 authentication headers, these will be passed by Git to credential helpers\&.
221 \fIWWW\-Authenticate\fR
222 header value is passed as a multi\-valued attribute
223 \fIwwwauth[]\fR, where the order of the attributes is the same as they appear in the HTTP response\&. This attribute is
225 from Git to pass additional information to credential helpers\&.
228 Unrecognised attributes are silently discarded\&.
231 Part of the \fBgit\fR(1) suite