1GITCREDENTIALS(7)                 Git Manual                 GITCREDENTIALS(7)
2
3
4

NAME

6       gitcredentials - providing usernames and passwords to Git
7

SYNOPSIS

9       git config credential.https://example.com.username myusername
10       git config credential.helper "$helper $options"
11
12

DESCRIPTION

14       Git will sometimes need credentials from the user in order to perform
15       operations; for example, it may need to ask for a username and password
16       in order to access a remote repository over HTTP. This manual describes
17       the mechanisms Git uses to request these credentials, as well as some
18       features to avoid inputting these credentials repeatedly.
19

REQUESTING CREDENTIALS

21       Without any credential helpers defined, Git will try the following
22       strategies to ask the user for usernames and passwords:
23
24        1. If the GIT_ASKPASS environment variable is set, the program
25           specified by the variable is invoked. A suitable prompt is provided
26           to the program on the command line, and the user’s input is read
27           from its standard output.
28
29        2. Otherwise, if the core.askPass configuration variable is set, its
30           value is used as above.
31
32        3. Otherwise, if the SSH_ASKPASS environment variable is set, its
33           value is used as above.
34
35        4. Otherwise, the user is prompted on the terminal.
36

AVOIDING REPETITION

38       It can be cumbersome to input the same credentials over and over. Git
39       provides two methods to reduce this annoyance:
40
41        1. Static configuration of usernames for a given authentication
42           context.
43
44        2. Credential helpers to cache or store passwords, or to interact with
45           a system password wallet or keychain.
46
47       The first is simple and appropriate if you do not have secure storage
48       available for a password. It is generally configured by adding this to
49       your config:
50
51           [credential "https://example.com"]
52                   username = me
53
54
55       Credential helpers, on the other hand, are external programs from which
56       Git can request both usernames and passwords; they typically interface
57       with secure storage provided by the OS or other programs.
58
59       To use a helper, you must first select one to use. Git currently
60       includes the following helpers:
61
62       cache
63           Cache credentials in memory for a short period of time. See git-
64           credential-cache(1) for details.
65
66       store
67           Store credentials indefinitely on disk. See git-credential-store(1)
68           for details.
69
70       You may also have third-party helpers installed; search for
71       credential-* in the output of git help -a, and consult the
72       documentation of individual helpers. Once you have selected a helper,
73       you can tell Git to use it by putting its name into the
74       credential.helper variable.
75
76        1. Find a helper.
77
78               $ git help -a | grep credential-
79               credential-foo
80
81
82        2. Read its description.
83
84               $ git help credential-foo
85
86
87        3. Tell Git to use it.
88
89               $ git config --global credential.helper foo
90
91

CREDENTIAL CONTEXTS

93       Git considers each credential to have a context defined by a URL. This
94       context is used to look up context-specific configuration, and is
95       passed to any helpers, which may use it as an index into secure
96       storage.
97
98       For instance, imagine we are accessing https://example.com/foo.git.
99       When Git looks into a config file to see if a section matches this
100       context, it will consider the two a match if the context is a
101       more-specific subset of the pattern in the config file. For example, if
102       you have this in your config file:
103
104           [credential "https://example.com"]
105                   username = foo
106
107
108       then we will match: both protocols are the same, both hosts are the
109       same, and the "pattern" URL does not care about the path component at
110       all. However, this context would not match:
111
112           [credential "https://kernel.org"]
113                   username = foo
114
115
116       because the hostnames differ. Nor would it match foo.example.com; Git
117       compares hostnames exactly, without considering whether two hosts are
118       part of the same domain. Likewise, a config entry for
119       http://example.com would not match: Git compares the protocols exactly.
120
121       If the "pattern" URL does include a path component, then this too must
122       match exactly: the context https://example.com/bar/baz.git will match a
123       config entry for https://example.com/bar/baz.git (in addition to
124       matching the config entry for https://example.com) but will not match a
125       config entry for https://example.com/bar.
126

CONFIGURATION OPTIONS

128       Options for a credential context can be configured either in
129       credential.* (which applies to all credentials), or credential.<url>.*,
130       where <url> matches the context as described above.
131
132       The following options are available in either location:
133
134       helper
135           The name of an external credential helper, and any associated
136           options. If the helper name is not an absolute path, then the
137           string git credential- is prepended. The resulting string is
138           executed by the shell (so, for example, setting this to foo
139           --option=bar will execute git credential-foo --option=bar via the
140           shell. See the manual of specific helpers for examples of their
141           use.
142
143           If there are multiple instances of the credential.helper
144           configuration variable, each helper will be tried in turn, and may
145           provide a username, password, or nothing. Once Git has acquired
146           both a username and a password, no more helpers will be tried.
147
148           If credential.helper is configured to the empty string, this resets
149           the helper list to empty (so you may override a helper set by a
150           lower-priority config file by configuring the empty-string helper,
151           followed by whatever set of helpers you would like).
152
153       username
154           A default username, if one is not provided in the URL.
155
156       useHttpPath
157           By default, Git does not consider the "path" component of an http
158           URL to be worth matching via external helpers. This means that a
159           credential stored for https://example.com/foo.git will also be used
160           for https://example.com/bar.git. If you do want to distinguish
161           these cases, set this option to true.
162

CUSTOM HELPERS

164       You can write your own custom helpers to interface with any system in
165       which you keep credentials. See the documentation for Git’s credentials
166       API[1] for details.
167

GIT

169       Part of the git(1) suite
170

NOTES

172        1. credentials API
173           file:///usr/share/doc/git/technical/api-credentials.html
174
175
176
177Git 2.24.1                        12/10/2019                 GITCREDENTIALS(7)
Impressum