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
11

DESCRIPTION

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

TYPICAL USE OF GIT CREDENTIAL

43       An application using git-credential will typically use git credential
44       following these steps:
45
46        1. Generate a credential description based on the context.
47
48           For example, if we want a password for https://example.com/foo.git,
49           we might generate the following credential description (don’t
50           forget the blank line at the end; it tells git credential that the
51           application finished feeding all the information it has):
52
53               protocol=https
54               host=example.com
55               path=foo.git
56
57        2. Ask git-credential to give us a username and password for this
58           description. This is done by running git credential fill, feeding
59           the description from step (1) to its standard input. The complete
60           credential description (including the credential per se, i.e. the
61           login and password) will be produced on standard output, like:
62
63               protocol=https
64               host=example.com
65               username=bob
66               password=secr3t
67
68           In most cases, this means the attributes given in the input will be
69           repeated in the output, but Git may also modify the credential
70           description, for example by removing the path attribute when the
71           protocol is HTTP(s) and credential.useHttpPath is false.
72
73           If the git credential knew about the password, this step may not
74           have involved the user actually typing this password (the user may
75           have typed a password to unlock the keychain instead, or no user
76           interaction was done if the keychain was already unlocked) before
77           it returned password=secr3t.
78
79        3. Use the credential (e.g., access the URL with the username and
80           password from step (2)), and see if it’s accepted.
81
82        4. Report on the success or failure of the password. If the credential
83           allowed the operation to complete successfully, then it can be
84           marked with an "approve" action to tell git credential to reuse it
85           in its next invocation. If the credential was rejected during the
86           operation, use the "reject" action so that git credential will ask
87           for a new password in its next invocation. In either case, git
88           credential should be fed with the credential description obtained
89           from step (2) (which also contain the ones provided in step (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/password information (e.g. host, protocol, path), or to the
96       actual credential data to be obtained (login/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. The key may
101       contain any bytes except =, newline, or NUL. The value may contain any
102       bytes except newline or NUL. In both cases, all bytes are treated as-is
103       (i.e., there is no quoting, and one cannot transmit a value with
104       newline or NUL in it). The list of attributes is terminated by a blank
105       line or end-of-file. Git understands the following attributes:
106
107       protocol
108           The protocol over which the credential will be used (e.g., https).
109
110       host
111           The remote hostname for a network credential.
112
113       path
114           The path with which the credential will be used. E.g., for
115           accessing a remote https repository, this will be the repository’s
116           path on the server.
117
118       username
119           The credential’s username, if we already have one (e.g., from a
120           URL, from the user, or from a previously run helper).
121
122       password
123           The credential’s password, if we are asking it to be stored.
124
125       url
126           When this special attribute is read by git credential, the value is
127           parsed as a URL and treated as if its constituent parts were read
128           (e.g., url=https://example.com would behave as if protocol=https
129           and host=example.com had been provided). This can help callers
130           avoid parsing URLs themselves. Note that any components which are
131           missing from the URL (e.g., there is no username in the example
132           above) will be set to empty; if you want to provide a URL and
133           override some attributes, provide the URL attribute first, followed
134           by any overrides.
135

NOTES

137        1. the Git credential API
138           file:///usr/share/doc/git/technical/api-credentials.html
139
140
141
142Git 2.21.0                        02/24/2019                 GIT-CREDENTIAL(1)
Impressum