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.39.1.231.ga7caae2729
10 .TH "GIT\-CREDENTIAL" "1" "01/17/2023" "Git 2\&.39\&.1\&.231\&.ga7caae" "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 credential 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 In both 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\&.
156 Git understands the following attributes:
160 The protocol over which the credential will be used (e\&.g\&.,
166 The remote hostname for a network credential\&. This includes the port number if one was specified (e\&.g\&., "example\&.com:8088")\&.
171 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\&.
176 The credential\(cqs username, if we already have one (e\&.g\&., from a URL, the configuration, the user, or from a previously run helper)\&.
181 The credential\(cqs password, if we are asking it to be stored\&.
186 When this special attribute is read by
187 \fBgit credential\fR, the value is parsed as a URL and treated as if its constituent parts were read (e\&.g\&.,
188 \fBurl=https://example\&.com\fR
192 \fBhost=example\&.com\fR
193 had been provided)\&. This can help callers avoid parsing URLs themselves\&.
195 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\&.
197 Components which are missing from the URL (e\&.g\&., there is no username in the example above) will be left unset\&.
200 Unrecognised attributes are silently discarded\&.
203 Part of the \fBgit\fR(1) suite