Updated git_doc to git 1.8
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / gitcredentials.xml
blob077826af257f9eef1d8a067beb5b28b62f56676a
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 </simplesect>\r
139 <simplesect id="gitcredentials(7)__credential_contexts">\r
140 <title>CREDENTIAL CONTEXTS</title>\r
141 <simpara>Git considers each credential to have a context defined by a URL. This context\r
142 is used to look up context-specific configuration, and is passed to any\r
143 helpers, which may use it as an index into secure storage.</simpara>\r
144 <simpara>For instance, imagine we are accessing <emphasis>https://example.com/foo.git</emphasis>. When git\r
145 looks into a config file to see if a section matches this context, it will\r
146 consider the two a match if the context is a more-specific subset of the\r
147 pattern in the config file. For example, if you have this in your config file:</simpara>\r
148 <screen>[credential "https://example.com"]\r
149         username = foo</screen>\r
150 <simpara>then we will match: both protocols are the same, both hosts are the same, and\r
151 the "pattern" URL does not care about the path component at all. However, this\r
152 context would not match:</simpara>\r
153 <screen>[credential "https://kernel.org"]\r
154         username = foo</screen>\r
155 <simpara>because the hostnames differ. Nor would it match <emphasis>foo.example.com</emphasis>; git\r
156 compares hostnames exactly, without considering whether two hosts are part of\r
157 the same domain. Likewise, a config entry for <emphasis>http://example.com</emphasis> would not\r
158 match: git compares the protocols exactly.</simpara>\r
159 </simplesect>\r
160 <simplesect id="gitcredentials(7)__configuration_options">\r
161 <title>CONFIGURATION OPTIONS</title>\r
162 <simpara>Options for a credential context can be configured either in\r
163 <emphasis>credential.*</emphasis> (which applies to all credentials), or\r
164 <emphasis>credential.&lt;url&gt;.*</emphasis>, where &lt;url&gt; matches the context as described\r
165 above.</simpara>\r
166 <simpara>The following options are available in either location:</simpara>\r
167 <variablelist>\r
168 <varlistentry>\r
169 <term>\r
170 helper\r
171 </term>\r
172 <listitem>\r
173 <simpara>\r
174         The name of an external credential helper, and any associated options.\r
175         If the helper name is not an absolute path, then the string <emphasis>git\r
176         credential-</emphasis> is prepended. The resulting string is executed by the\r
177         shell (so, for example, setting this to <emphasis>foo --option=bar</emphasis> will execute\r
178         <emphasis>git credential-foo --option=bar</emphasis> via the shell. See the manual of\r
179         specific helpers for examples of their use.\r
180 </simpara>\r
181 </listitem>\r
182 </varlistentry>\r
183 <varlistentry>\r
184 <term>\r
185 username\r
186 </term>\r
187 <listitem>\r
188 <simpara>\r
189         A default username, if one is not provided in the URL.\r
190 </simpara>\r
191 </listitem>\r
192 </varlistentry>\r
193 <varlistentry>\r
194 <term>\r
195 useHttpPath\r
196 </term>\r
197 <listitem>\r
198 <simpara>\r
199         By default, git does not consider the "path" component of an http URL\r
200         to be worth matching via external helpers. This means that a credential\r
201         stored for <emphasis>https://example.com/foo.git</emphasis> will also be used for\r
202         <emphasis>https://example.com/bar.git</emphasis>. If you do want to distinguish these\r
203         cases, set this option to <emphasis>true</emphasis>.\r
204 </simpara>\r
205 </listitem>\r
206 </varlistentry>\r
207 </variablelist>\r
208 </simplesect>\r
209 <simplesect id="gitcredentials(7)__custom_helpers">\r
210 <title>CUSTOM HELPERS</title>\r
211 <simpara>You can write your own custom helpers to interface with any system in\r
212 which you keep credentials. See the documentation for git's\r
213 link:technical/api-credentials.html[credentials API] for details.</simpara>\r
214 </simplesect>\r
215 <simplesect id="gitcredentials(7)__git">\r
216 <title>GIT</title>\r
217 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
218 </simplesect>\r
219 </sect2>\r