Fix some links
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / gitcredentials.xml
blob7db0cc0ce8912f10d051c8aa222a36bce8ec6113
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="gitcredentials(7)">\r
5     <title>gitcredentials(7)</title>\r
6 <indexterm>\r
7 <primary>gitcredentials(7)</primary>\r
8 </indexterm>\r
9 <simplesect id="gitcredentials(7)__name">\r
10 <title>NAME</title>\r
11 <simpara>gitcredentials - providing usernames and passwords to Git</simpara>\r
12 </simplesect>\r
13 <simplesect id="gitcredentials(7)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <screen>git config credential.https://example.com.username myusername\r
16 git config credential.helper "$helper $options"</screen>\r
17 </simplesect>\r
18 <simplesect id="gitcredentials(7)__description">\r
19 <title>DESCRIPTION</title>\r
20 <simpara>Git will sometimes need credentials from the user in order to perform\r
21 operations; for example, it may need to ask for a username and password\r
22 in order to access a remote repository over HTTP. This manual describes\r
23 the mechanisms Git uses to request these credentials, as well as some\r
24 features to avoid inputting these credentials repeatedly.</simpara>\r
25 </simplesect>\r
26 <simplesect id="gitcredentials(7)__requesting_credentials">\r
27 <title>REQUESTING CREDENTIALS</title>\r
28 <simpara>Without any credential helpers defined, Git will try the following\r
29 strategies to ask the user for usernames and passwords:</simpara>\r
30 <orderedlist numeration="arabic">\r
31 <listitem>\r
32 <simpara>\r
33 If the <emphasis>GIT_ASKPASS</emphasis> environment variable is set, the program\r
34    specified by the variable is invoked. A suitable prompt is provided\r
35    to the program on the command line, and the user's input is read\r
36    from its standard output.\r
37 </simpara>\r
38 </listitem>\r
39 <listitem>\r
40 <simpara>\r
41 Otherwise, if the <emphasis>core.askPass</emphasis> configuration variable is set, its\r
42    value is used as above.\r
43 </simpara>\r
44 </listitem>\r
45 <listitem>\r
46 <simpara>\r
47 Otherwise, if the <emphasis>SSH_ASKPASS</emphasis> environment variable is set, its\r
48    value is used as above.\r
49 </simpara>\r
50 </listitem>\r
51 <listitem>\r
52 <simpara>\r
53 Otherwise, the user is prompted on the terminal.\r
54 </simpara>\r
55 </listitem>\r
56 </orderedlist>\r
57 </simplesect>\r
58 <simplesect id="gitcredentials(7)__avoiding_repetition">\r
59 <title>AVOIDING REPETITION</title>\r
60 <simpara>It can be cumbersome to input the same credentials over and over.  Git\r
61 provides two methods to reduce this annoyance:</simpara>\r
62 <orderedlist numeration="arabic">\r
63 <listitem>\r
64 <simpara>\r
65 Static configuration of usernames for a given authentication context.\r
66 </simpara>\r
67 </listitem>\r
68 <listitem>\r
69 <simpara>\r
70 Credential helpers to cache or store passwords, or to interact with\r
71    a system password wallet or keychain.\r
72 </simpara>\r
73 </listitem>\r
74 </orderedlist>\r
75 <simpara>The first is simple and appropriate if you do not have secure storage available\r
76 for a password. It is generally configured by adding this to your config:</simpara>\r
77 <screen>[credential "https://example.com"]\r
78         username = me</screen>\r
79 <simpara>Credential helpers, on the other hand, are external programs from which Git can\r
80 request both usernames and passwords; they typically interface with secure\r
81 storage provided by the OS or other programs.</simpara>\r
82 <simpara>To use a helper, you must first select one to use. Git currently\r
83 includes the following helpers:</simpara>\r
84 <variablelist>\r
85 <varlistentry>\r
86 <term>\r
87 cache\r
88 </term>\r
89 <listitem>\r
90 <simpara>\r
91         Cache credentials in memory for a short period of time. See\r
92         <xref linkend="git-credential-cache(1)" /> for details.\r
93 </simpara>\r
94 </listitem>\r
95 </varlistentry>\r
96 <varlistentry>\r
97 <term>\r
98 store\r
99 </term>\r
100 <listitem>\r
101 <simpara>\r
102         Store credentials indefinitely on disk. See\r
103         <xref linkend="git-credential-store(1)" /> for details.\r
104 </simpara>\r
105 </listitem>\r
106 </varlistentry>\r
107 </variablelist>\r
108 <simpara>You may also have third-party helpers installed; search for\r
109 <emphasis>credential-*</emphasis> in the output of <emphasis>git help -a</emphasis>, and consult the\r
110 documentation of individual helpers.  Once you have selected a helper,\r
111 you can tell Git to use it by putting its name into the\r
112 credential.helper variable.</simpara>\r
113 <orderedlist numeration="arabic">\r
114 <listitem>\r
115 <simpara>\r
116 Find a helper.\r
117 </simpara>\r
118 <screen>$ git help -a | grep credential-\r
119 credential-foo</screen>\r
120 </listitem>\r
121 <listitem>\r
122 <simpara>\r
123 Read its description.\r
124 </simpara>\r
125 <screen>$ git help credential-foo</screen>\r
126 </listitem>\r
127 <listitem>\r
128 <simpara>\r
129 Tell Git to use it.\r
130 </simpara>\r
131 <screen>$ git config --global credential.helper foo</screen>\r
132 </listitem>\r
133 </orderedlist>\r
134 <simpara>If there are multiple instances of the <emphasis>credential.helper</emphasis> configuration\r
135 variable, each helper will be tried in turn, and may provide a username,\r
136 password, or nothing. Once Git has acquired both a username and a\r
137 password, no more helpers will be tried.</simpara>\r
138 <simpara>If <emphasis>credential.helper</emphasis> is configured to the empty string, this resets\r
139 the helper list to empty (so you may override a helper set by a\r
140 lower-priority config file by configuring the empty-string helper,\r
141 followed by whatever set of helpers you would like).</simpara>\r
142 </simplesect>\r
143 <simplesect id="gitcredentials(7)__credential_contexts">\r
144 <title>CREDENTIAL CONTEXTS</title>\r
145 <simpara>Git considers each credential to have a context defined by a URL. This context\r
146 is used to look up context-specific configuration, and is passed to any\r
147 helpers, which may use it as an index into secure storage.</simpara>\r
148 <simpara>For instance, imagine we are accessing <emphasis>https://example.com/foo.git</emphasis>. When Git\r
149 looks into a config file to see if a section matches this context, it will\r
150 consider the two a match if the context is a more-specific subset of the\r
151 pattern in the config file. For example, if you have this in your config file:</simpara>\r
152 <screen>[credential "https://example.com"]\r
153         username = foo</screen>\r
154 <simpara>then we will match: both protocols are the same, both hosts are the same, and\r
155 the "pattern" URL does not care about the path component at all. However, this\r
156 context would not match:</simpara>\r
157 <screen>[credential "https://kernel.org"]\r
158         username = foo</screen>\r
159 <simpara>because the hostnames differ. Nor would it match <emphasis>foo.example.com</emphasis>; Git\r
160 compares hostnames exactly, without considering whether two hosts are part of\r
161 the same domain. Likewise, a config entry for <emphasis>http://example.com</emphasis> would not\r
162 match: Git compares the protocols exactly.</simpara>\r
163 </simplesect>\r
164 <simplesect id="gitcredentials(7)__configuration_options">\r
165 <title>CONFIGURATION OPTIONS</title>\r
166 <simpara>Options for a credential context can be configured either in\r
167 <emphasis>credential.*</emphasis> (which applies to all credentials), or\r
168 <emphasis>credential.&lt;url&gt;.*</emphasis>, where &lt;url&gt; matches the context as described\r
169 above.</simpara>\r
170 <simpara>The following options are available in either location:</simpara>\r
171 <variablelist>\r
172 <varlistentry>\r
173 <term>\r
174 helper\r
175 </term>\r
176 <listitem>\r
177 <simpara>\r
178         The name of an external credential helper, and any associated options.\r
179         If the helper name is not an absolute path, then the string <emphasis>git\r
180         credential-</emphasis> is prepended. The resulting string is executed by the\r
181         shell (so, for example, setting this to <emphasis>foo --option=bar</emphasis> will execute\r
182         <emphasis>git credential-foo --option=bar</emphasis> via the shell. See the manual of\r
183         specific helpers for examples of their use.\r
184 </simpara>\r
185 </listitem>\r
186 </varlistentry>\r
187 <varlistentry>\r
188 <term>\r
189 username\r
190 </term>\r
191 <listitem>\r
192 <simpara>\r
193         A default username, if one is not provided in the URL.\r
194 </simpara>\r
195 </listitem>\r
196 </varlistentry>\r
197 <varlistentry>\r
198 <term>\r
199 useHttpPath\r
200 </term>\r
201 <listitem>\r
202 <simpara>\r
203         By default, Git does not consider the "path" component of an http URL\r
204         to be worth matching via external helpers. This means that a credential\r
205         stored for <emphasis>https://example.com/foo.git</emphasis> will also be used for\r
206         <emphasis>https://example.com/bar.git</emphasis>. If you do want to distinguish these\r
207         cases, set this option to <emphasis>true</emphasis>.\r
208 </simpara>\r
209 </listitem>\r
210 </varlistentry>\r
211 </variablelist>\r
212 </simplesect>\r
213 <simplesect id="gitcredentials(7)__custom_helpers">\r
214 <title>CUSTOM HELPERS</title>\r
215 <simpara>You can write your own custom helpers to interface with any system in\r
216 which you keep credentials. See the documentation for Git's\r
217 <ulink url="https://www.kernel.org/pub/software/scm/git/docs/technical/api-credentials.html"><citetitle>credentials API</citetitle></ulink> for details.</simpara>\r
218 </simplesect>\r
219 <simplesect id="gitcredentials(7)__git">\r
220 <title>GIT</title>\r
221 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
222 </simplesect>\r
223 </sect2>\r