1GIT-CREDENTIAL(1)                 Git Manual                 GIT-CREDENTIAL(1)
2
3
4

NAME

6       git-credential - Retrieve and store user credentials
7

SYNOPSIS

9       'git credential' (fill|approve|reject)
10

DESCRIPTION

12       Git has an internal interface for storing and retrieving credentials
13       from system-specific helpers, as well as prompting the user for
14       usernames and passwords. The git-credential command exposes this
15       interface to scripts which may want to retrieve, store, or prompt for
16       credentials in the same manner as Git. The design of this scriptable
17       interface models the internal C API; see credential.h for more
18       background on the concepts.
19
20       git-credential takes an "action" option on the command-line (one of
21       fill, approve, or reject) and reads a credential description on stdin
22       (see INPUT/OUTPUT FORMAT).
23
24       If the action is fill, git-credential will attempt to add "username"
25       and "password" attributes to the description by reading config files,
26       by contacting any configured credential helpers, or by prompting the
27       user. The username and password attributes of the credential
28       description are then printed to stdout together with the attributes
29       already provided.
30
31       If the action is approve, git-credential will send the description to
32       any configured credential helpers, which may store the credential for
33       later use.
34
35       If the action is reject, git-credential will send the description to
36       any configured credential helpers, which may erase any stored
37       credentials matching the description.
38
39       If the action is approve or reject, no output should be emitted.
40

TYPICAL USE OF GIT CREDENTIAL

42       An application using git-credential will typically use git credential
43       following these steps:
44
45        1. Generate a credential description based on the context.
46
47           For example, if we want a password for https://example.com/foo.git,
48           we might generate the following credential description (don’t
49           forget the blank line at the end; it tells git credential that the
50           application finished feeding all the information it has):
51
52               protocol=https
53               host=example.com
54               path=foo.git
55
56        2. Ask git-credential to give us a username and password for this
57           description. This is done by running git credential fill, feeding
58           the description from step (1) to its standard input. The complete
59           credential description (including the credential per se, i.e. the
60           login and password) will be produced on standard output, like:
61
62               protocol=https
63               host=example.com
64               username=bob
65               password=secr3t
66
67           In most cases, this means the attributes given in the input will be
68           repeated in the output, but Git may also modify the credential
69           description, for example by removing the path attribute when the
70           protocol is HTTP(s) and credential.useHttpPath is false.
71
72           If the git credential knew about the password, this step may not
73           have involved the user actually typing this password (the user may
74           have typed a password to unlock the keychain instead, or no user
75           interaction was done if the keychain was already unlocked) before
76           it returned password=secr3t.
77
78        3. Use the credential (e.g., access the URL with the username and
79           password from step (2)), and see if it’s accepted.
80
81        4. Report on the success or failure of the password. If the credential
82           allowed the operation to complete successfully, then it can be
83           marked with an "approve" action to tell git credential to reuse it
84           in its next invocation. If the credential was rejected during the
85           operation, use the "reject" action so that git credential will ask
86           for a new password in its next invocation. In either case, git
87           credential should be fed with the credential description obtained
88           from step (2) (which also contains the fields provided in step
89           (1)).
90

INPUT/OUTPUT FORMAT

92       git credential reads and/or writes (depending on the action used)
93       credential information in its standard input/output. This information
94       can correspond either to keys for which git credential will obtain the
95       login information (e.g. host, protocol, path), or to the actual
96       credential data to be obtained (username/password).
97
98       The credential is split into a set of named attributes, with one
99       attribute per line. Each attribute is specified by a key-value pair,
100       separated by an = (equals) sign, followed by a newline.
101
102       The key may contain any bytes except =, newline, or NUL. The value may
103       contain any bytes except newline or NUL.
104
105       Attributes with keys that end with C-style array brackets [] can have
106       multiple values. Each instance of a multi-valued attribute forms an
107       ordered list of values - the order of the repeated attributes defines
108       the order of the values. An empty multi-valued attribute (key[]=\n)
109       acts to clear any previous entries and reset the list.
110
111       In all cases, all bytes are treated as-is (i.e., there is no quoting,
112       and one cannot transmit a value with newline or NUL in it). The list of
113       attributes is terminated by a blank line or end-of-file.
114
115       Git understands the following attributes:
116
117       protocol
118           The protocol over which the credential will be used (e.g., https).
119
120       host
121           The remote hostname for a network credential. This includes the
122           port number if one was specified (e.g., "example.com:8088").
123
124       path
125           The path with which the credential will be used. E.g., for
126           accessing a remote https repository, this will be the repository’s
127           path on the server.
128
129       username
130           The credential’s username, if we already have one (e.g., from a
131           URL, the configuration, the user, or from a previously run helper).
132
133       password
134           The credential’s password, if we are asking it to be stored.
135
136       password_expiry_utc
137           Generated passwords such as an OAuth access token may have an
138           expiry date. When reading credentials from helpers, git credential
139           fill ignores expired passwords. Represented as Unix time UTC,
140           seconds since 1970.
141
142       oauth_refresh_token
143           An OAuth refresh token may accompany a password that is an OAuth
144           access token. Helpers must treat this attribute as confidential
145           like the password attribute. Git itself has no special behaviour
146           for this attribute.
147
148       url
149           When this special attribute is read by git credential, the value is
150           parsed as a URL and treated as if its constituent parts were read
151           (e.g., url=https://example.com would behave as if protocol=https
152           and host=example.com had been provided). This can help callers
153           avoid parsing URLs themselves.
154
155           Note that specifying a protocol is mandatory and if the URL doesn’t
156           specify a hostname (e.g., "cert:///path/to/file") the credential
157           will contain a hostname attribute whose value is an empty string.
158
159           Components which are missing from the URL (e.g., there is no
160           username in the example above) will be left unset.
161
162       wwwauth[]
163           When an HTTP response is received by Git that includes one or more
164           WWW-Authenticate authentication headers, these will be passed by
165           Git to credential helpers.
166
167           Each WWW-Authenticate header value is passed as a multi-valued
168           attribute wwwauth[], where the order of the attributes is the same
169           as they appear in the HTTP response. This attribute is one-way from
170           Git to pass additional information to credential helpers.
171
172       Unrecognised attributes are silently discarded.
173

GIT

175       Part of the git(1) suite
176
177
178
179Git 2.43.0                        11/20/2023                 GIT-CREDENTIAL(1)
Impressum