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

CONFIGURATION OPTIONS

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

CUSTOM HELPERS

158       You can write your own custom helpers to interface with any system in
159       which you keep credentials. See the documentation for Git’s credentials
160       API[1] for details.
161

GIT

163       Part of the git(1) suite
164

NOTES

166        1. credentials API
167           file:///usr/share/doc/git/technical/api-credentials.html
168
169
170
171Git 2.18.1                        05/14/2019                 GITCREDENTIALS(7)
Impressum