updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-http-backend.xml
blob921c967f65de6eea4b175b43e27202e3be0febee
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-http-backend(1)">\r
5 <articleinfo>\r
6     <title>git-http-backend(1)</title>\r
7 <indexterm>\r
8 <primary>git-http-backend(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-http-backend - Server side implementation of Git over HTTP</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git http-backend</emphasis></literallayout>\r
19 </blockquote>\r
20 </simplesect>\r
21 <simplesect id="_description">\r
22 <title>DESCRIPTION</title>\r
23 <simpara>A simple CGI program to serve the contents of a Git repository to Git\r
24 clients accessing the repository over http:// and https:// protocols.\r
25 The program supports clients fetching using both the smart HTTP protocol\r
26 and the backwards-compatible dumb HTTP protocol, as well as clients\r
27 pushing using the smart HTTP protocol.</simpara>\r
28 <simpara>It verifies that the directory has the magic file\r
29 "git-daemon-export-ok", and it will refuse to export any git directory\r
30 that hasn't explicitly been marked for export this way (unless the\r
31 GIT_HTTP_EXPORT_ALL environmental variable is set).</simpara>\r
32 <simpara>By default, only the <emphasis>upload-pack</emphasis> service is enabled, which serves\r
33 <emphasis>git fetch-pack</emphasis> and <emphasis>git ls-remote</emphasis> clients, which are invoked from\r
34 <emphasis>git fetch</emphasis>, <emphasis>git pull</emphasis>, and <emphasis>git clone</emphasis>.  If the client is authenticated,\r
35 the <emphasis>receive-pack</emphasis> service is enabled, which serves <emphasis>git send-pack</emphasis>\r
36 clients, which is invoked from <emphasis>git push</emphasis>.</simpara>\r
37 </simplesect>\r
38 <simplesect id="_services">\r
39 <title>SERVICES</title>\r
40 <simpara>These services can be enabled/disabled using the per-repository\r
41 configuration file:</simpara>\r
42 <variablelist>\r
43 <varlistentry>\r
44 <term>\r
45 http.getanyfile\r
46 </term>\r
47 <listitem>\r
48 <simpara>\r
49         This serves Git clients older than version 1.6.6 that are unable to use the\r
50         upload pack service.  When enabled, clients are able to read\r
51         any file within the repository, including objects that are\r
52         no longer reachable from a branch but are still present.\r
53         It is enabled by default, but a repository can disable it\r
54         by setting this configuration item to <emphasis>false</emphasis>.\r
55 </simpara>\r
56 </listitem>\r
57 </varlistentry>\r
58 <varlistentry>\r
59 <term>\r
60 http.uploadpack\r
61 </term>\r
62 <listitem>\r
63 <simpara>\r
64         This serves <emphasis>git fetch-pack</emphasis> and <emphasis>git ls-remote</emphasis> clients.\r
65         It is enabled by default, but a repository can disable it\r
66         by setting this configuration item to <emphasis>false</emphasis>.\r
67 </simpara>\r
68 </listitem>\r
69 </varlistentry>\r
70 <varlistentry>\r
71 <term>\r
72 http.receivepack\r
73 </term>\r
74 <listitem>\r
75 <simpara>\r
76         This serves <emphasis>git send-pack</emphasis> clients, allowing push.  It is\r
77         disabled by default for anonymous users, and enabled by\r
78         default for users authenticated by the web server.  It can be\r
79         disabled by setting this item to <emphasis>false</emphasis>, or enabled for all\r
80         users, including anonymous users, by setting it to <emphasis>true</emphasis>.\r
81 </simpara>\r
82 </listitem>\r
83 </varlistentry>\r
84 </variablelist>\r
85 </simplesect>\r
86 <simplesect id="_url_translation">\r
87 <title>URL TRANSLATION</title>\r
88 <simpara>To determine the location of the repository on disk, <emphasis>git http-backend</emphasis>\r
89 concatenates the environment variables PATH_INFO, which is set\r
90 automatically by the web server, and GIT_PROJECT_ROOT, which must be set\r
91 manually in the web server configuration.  If GIT_PROJECT_ROOT is not\r
92 set, <emphasis>git http-backend</emphasis> reads PATH_TRANSLATED, which is also set\r
93 automatically by the web server.</simpara>\r
94 </simplesect>\r
95 <simplesect id="_examples">\r
96 <title>EXAMPLES</title>\r
97 <simpara>All of the following examples map <emphasis>http://$hostname/git/foo/bar.git</emphasis>\r
98 to <emphasis>/var/www/git/foo/bar.git</emphasis>.</simpara>\r
99 <variablelist>\r
100 <varlistentry>\r
101 <term>\r
102 Apache 2.x\r
103 </term>\r
104 <listitem>\r
105 <simpara>\r
106         Ensure mod_cgi, mod_alias, and mod_env are enabled, set\r
107         GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and\r
108         create a ScriptAlias to the CGI:\r
109 </simpara>\r
110 <screen>SetEnv GIT_PROJECT_ROOT /var/www/git\r
111 SetEnv GIT_HTTP_EXPORT_ALL\r
112 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/</screen>\r
113 <simpara>To enable anonymous read access but authenticated write access,\r
114 require authorization with a LocationMatch directive:</simpara>\r
115 <screen>&lt;LocationMatch "^/git/.*/git-receive-pack$"&gt;\r
116         AuthType Basic\r
117         AuthName "Git Access"\r
118         Require group committers\r
119         ...\r
120 &lt;/LocationMatch&gt;</screen>\r
121 <simpara>To require authentication for both reads and writes, use a Location\r
122 directive around the repository, or one of its parent directories:</simpara>\r
123 <screen>&lt;Location /git/private&gt;\r
124         AuthType Basic\r
125         AuthName "Private Git Access"\r
126         Require group committers\r
127         ...\r
128 &lt;/Location&gt;</screen>\r
129 <simpara>To serve gitweb at the same url, use a ScriptAliasMatch to only\r
130 those URLs that <emphasis>git http-backend</emphasis> can handle, and forward the\r
131 rest to gitweb:</simpara>\r
132 <screen>ScriptAliasMatch \\r
133         "(?x)^/git/(.*/(HEAD | \\r
134                         info/refs | \\r
135                         objects/(info/[^/]+ | \\r
136                                  [0-9a-f]{2}/[0-9a-f]{38} | \\r
137                                  pack/pack-[0-9a-f]{40}\.(pack|idx)) | \\r
138                         git-(upload|receive)-pack))$" \\r
139         /usr/libexec/git-core/git-http-backend/$1\r
141 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/</screen>\r
142 <simpara>To serve multiple repositories from different <xref linkend="gitnamespaces(7)" /> in a\r
143 single repository:</simpara>\r
144 <screen>SetEnvIf Request_URI "^/git/([^/]*)" GIT_NAMESPACE=$1\r
145 ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1</screen>\r
146 </listitem>\r
147 </varlistentry>\r
148 <varlistentry>\r
149 <term>\r
150 Accelerated static Apache 2.x\r
151 </term>\r
152 <listitem>\r
153 <simpara>\r
154         Similar to the above, but Apache can be used to return static\r
155         files that are stored on disk.  On many systems this may\r
156         be more efficient as Apache can ask the kernel to copy the\r
157         file contents from the file system directly to the network:\r
158 </simpara>\r
159 <screen>SetEnv GIT_PROJECT_ROOT /var/www/git\r
161 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1\r
162 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1\r
163 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/</screen>\r
164 <simpara>This can be combined with the gitweb configuration:</simpara>\r
165 <screen>SetEnv GIT_PROJECT_ROOT /var/www/git\r
167 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1\r
168 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1\r
169 ScriptAliasMatch \\r
170         "(?x)^/git/(.*/(HEAD | \\r
171                         info/refs | \\r
172                         objects/info/[^/]+ | \\r
173                         git-(upload|receive)-pack))$" \\r
174         /usr/libexec/git-core/git-http-backend/$1\r
175 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/</screen>\r
176 </listitem>\r
177 </varlistentry>\r
178 </variablelist>\r
179 </simplesect>\r
180 <simplesect id="_environment">\r
181 <title>ENVIRONMENT</title>\r
182 <simpara><emphasis>git http-backend</emphasis> relies upon the CGI environment variables set\r
183 by the invoking web server, including:</simpara>\r
184 <itemizedlist>\r
185 <listitem>\r
186 <simpara>\r
187 PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)\r
188 </simpara>\r
189 </listitem>\r
190 <listitem>\r
191 <simpara>\r
192 REMOTE_USER\r
193 </simpara>\r
194 </listitem>\r
195 <listitem>\r
196 <simpara>\r
197 REMOTE_ADDR\r
198 </simpara>\r
199 </listitem>\r
200 <listitem>\r
201 <simpara>\r
202 CONTENT_TYPE\r
203 </simpara>\r
204 </listitem>\r
205 <listitem>\r
206 <simpara>\r
207 QUERY_STRING\r
208 </simpara>\r
209 </listitem>\r
210 <listitem>\r
211 <simpara>\r
212 REQUEST_METHOD\r
213 </simpara>\r
214 </listitem>\r
215 </itemizedlist>\r
216 <simpara>The GIT_HTTP_EXPORT_ALL environmental variable may be passed to\r
217 <emphasis>git-http-backend</emphasis> to bypass the check for the "git-daemon-export-ok"\r
218 file in each repository before allowing export of that repository.</simpara>\r
219 <simpara>The backend process sets GIT_COMMITTER_NAME to <emphasis>$REMOTE_USER</emphasis> and\r
220 GIT_COMMITTER_EMAIL to <emphasis>${REMOTE_USER}@http.${REMOTE_ADDR}</emphasis>,\r
221 ensuring that any reflogs created by <emphasis>git-receive-pack</emphasis> contain some\r
222 identifying information of the remote user who performed the push.</simpara>\r
223 <simpara>All CGI environment variables are available to each of the hooks\r
224 invoked by the <emphasis>git-receive-pack</emphasis>.</simpara>\r
225 </simplesect>\r
226 <simplesect id="_author">\r
227 <title>Author</title>\r
228 <simpara>Written by Shawn O. Pearce &lt;<ulink url="mailto:spearce@spearce.org">spearce@spearce.org</ulink>&gt;.</simpara>\r
229 </simplesect>\r
230 <simplesect id="_documentation">\r
231 <title>Documentation</title>\r
232 <simpara>Documentation by Shawn O. Pearce &lt;<ulink url="mailto:spearce@spearce.org">spearce@spearce.org</ulink>&gt;.</simpara>\r
233 </simplesect>\r
234 <simplesect id="_git">\r
235 <title>GIT</title>\r
236 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
237 </simplesect>\r
238 </article>\r