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
92       If there are multiple instances of the credential.helper configuration
93       variable, each helper will be tried in turn, and may provide a
94       username, password, or nothing. Once Git has acquired both a username
95       and a password, no more helpers will be tried.
96

CREDENTIAL CONTEXTS

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

CONFIGURATION OPTIONS

127       Options for a credential context can be configured either in
128       credential.* (which applies to all credentials), or credential.<url>.*,
129       where <url> matches the context as described above.
130
131       The following options are available in either location:
132
133       helper
134           The name of an external credential helper, and any associated
135           options. If the helper name is not an absolute path, then the
136           string git credential- is prepended. The resulting string is
137           executed by the shell (so, for example, setting this to foo
138           --option=bar will execute git credential-foo --option=bar via the
139           shell. See the manual of specific helpers for examples of their
140           use.
141
142       username
143           A default username, if one is not provided in the URL.
144
145       useHttpPath
146           By default, Git does not consider the "path" component of an http
147           URL to be worth matching via external helpers. This means that a
148           credential stored for https://example.com/foo.git will also be used
149           for https://example.com/bar.git. If you do want to distinguish
150           these cases, set this option to true.
151

CUSTOM HELPERS

153       You can write your own custom helpers to interface with any system in
154       which you keep credentials. See the documentation for Git’s credentials
155       API[1] for details.
156

GIT

158       Part of the git(1) suite
159

NOTES

161        1. credentials API
162           file:///usr/share/doc/git-1.8.3.1/technical/api-credentials.html
163
164
165
166Git 1.8.3.1                       11/19/2018                 GITCREDENTIALS(7)
Impressum