1git-credential(1) 2================= 3 4NAME 5---- 6git-credential - retrieve and store user credentials 7 8SYNOPSIS 9-------- 10------------------ 11git credential <fill|approve|reject> 12------------------ 13 14DESCRIPTION 15----------- 16 17Git has an internal interface for storing and retrieving credentials 18from system-specific helpers, as well as prompting the user for 19usernames and passwords. The git-credential command exposes this 20interface to scripts which may want to retrieve, store, or prompt for 21credentials in the same manner as git. The design of this scriptable 22interface models the internal C API; see 23link:technical/api-credentials.txt[the git credential API] for more 24background on the concepts. 25 26git-credential takes an "action" option on the command-line (one of 27`fill`, `approve`, or `reject`) and reads a credential description 28on stdin (see <<IOFMT,INPUT/OUTPUT FORMAT>>). 29 30If the action is `fill`, git-credential will attempt to add "username" 31and "password" attributes to the description by reading config files, 32by contacting any configured credential helpers, or by prompting the 33user. The username and password attributes of the credential 34description are then printed to stdout together with the attributes 35already provided. 36 37If the action is `approve`, git-credential will send the description 38to any configured credential helpers, which may store the credential 39for later use. 40 41If the action is `reject`, git-credential will send the description to 42any configured credential helpers, which may erase any stored 43credential matching the description. 44 45If the action is `approve` or `reject`, no output should be emitted. 46 47TYPICAL USE OF GIT CREDENTIAL 48----------------------------- 49 50An application using git-credential will typically use `git 51credential` following these steps: 52 53 1. Generate a credential description based on the context. 54+ 55For example, if we want a password for 56`https://example.com/foo.git`, we might generate the following 57credential description (don't forget the blank line at the end; it 58tells `git credential` that the application finished feeding all the 59infomation it has): 60 61 protocol=https 62 host=example.com 63 path=foo.git 64 65 2. Ask git-credential to give us a username and password for this 66 description. This is done by running `git credential fill`, 67 feeding the description from step (1) to its standard input. The 68 credential will be produced on standard output, like: 69 70 username=bob 71 password=secr3t 72+ 73If the `git credential` knew about the password, this step may 74not have involved the user actually typing this password (the 75user may have typed a password to unlock the keychain instead, 76or no user interaction was done if the keychain was already 77unlocked) before 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 83 credential allowed the operation to complete successfully, then 84 it can be marked with an "approve" action to tell `git 85 credential` to reuse it in its next invocation. If the credential 86 was rejected during the operation, use the "reject" action so 87 that `git credential` will ask for a new password in its next 88 invocation. In either case, `git credential` should be fed with 89 the credential description obtained from step (2) together with 90 the ones already provided in step (1). 91 92[[IOFMT]] 93INPUT/OUTPUT FORMAT 94------------------- 95 96`git credential` reads and/or writes (depending on the action used) 97credential information in its standard input/output. These information 98can correspond either to keys for which `git credential` will obtain 99the login/password information (e.g. host, protocol, path), or to the 100actual credential data to be obtained (login/password). 101 102The credential is split into a set of named attributes. 103Attributes are provided to the helper, one per line. Each attribute is 104specified by a key-value pair, separated by an `=` (equals) sign, 105followed by a newline. The key may contain any bytes except `=`, 106newline, or NUL. The value may contain any bytes except newline or NUL. 107In both cases, all bytes are treated as-is (i.e., there is no quoting, 108and one cannot transmit a value with newline or NUL in it). The list of 109attributes is terminated by a blank line or end-of-file. 110Git will send the following attributes (but may not send all of 111them for a given credential; for example, a `host` attribute makes no 112sense when dealing with a non-network protocol): 113 114`protocol`:: 115 116 The protocol over which the credential will be used (e.g., 117 `https`). 118 119`host`:: 120 121 The remote hostname for a network credential. 122 123`path`:: 124 125 The path with which the credential will be used. E.g., for 126 accessing a remote https repository, this will be the 127 repository's path on the server. 128 129`username`:: 130 131 The credential's username, if we already have one (e.g., from a 132 URL, from the user, or from a previously run helper). 133 134`password`:: 135 136 The credential's password, if we are asking it to be stored.