doc/http-backend: missing accent grave in literal mark-up
[git/debian.git] / Documentation / git-http-backend.txt
blob8d0da1519b603570f31007c9d6d204afe2996b57
1 git-http-backend(1)
2 ===================
4 NAME
5 ----
6 git-http-backend - Server side implementation of Git over HTTP
8 SYNOPSIS
9 --------
10 [verse]
11 'git http-backend'
13 DESCRIPTION
14 -----------
15 A simple CGI program to serve the contents of a Git repository to Git
16 clients accessing the repository over http:// and https:// protocols.
17 The program supports clients fetching using both the smart HTTP protocol
18 and the backwards-compatible dumb HTTP protocol, as well as clients
19 pushing using the smart HTTP protocol.
21 It verifies that the directory has the magic file
22 "git-daemon-export-ok", and it will refuse to export any Git directory
23 that hasn't explicitly been marked for export this way (unless the
24 GIT_HTTP_EXPORT_ALL environmental variable is set).
26 By default, only the `upload-pack` service is enabled, which serves
27 'git fetch-pack' and 'git ls-remote' clients, which are invoked from
28 'git fetch', 'git pull', and 'git clone'.  If the client is authenticated,
29 the `receive-pack` service is enabled, which serves 'git send-pack'
30 clients, which is invoked from 'git push'.
32 SERVICES
33 --------
34 These services can be enabled/disabled using the per-repository
35 configuration file:
37 http.getanyfile::
38         This serves Git clients older than version 1.6.6 that are unable to use the
39         upload pack service.  When enabled, clients are able to read
40         any file within the repository, including objects that are
41         no longer reachable from a branch but are still present.
42         It is enabled by default, but a repository can disable it
43         by setting this configuration item to `false`.
45 http.uploadpack::
46         This serves 'git fetch-pack' and 'git ls-remote' clients.
47         It is enabled by default, but a repository can disable it
48         by setting this configuration item to `false`.
50 http.receivepack::
51         This serves 'git send-pack' clients, allowing push.  It is
52         disabled by default for anonymous users, and enabled by
53         default for users authenticated by the web server.  It can be
54         disabled by setting this item to `false`, or enabled for all
55         users, including anonymous users, by setting it to `true`.
57 URL TRANSLATION
58 ---------------
59 To determine the location of the repository on disk, 'git http-backend'
60 concatenates the environment variables PATH_INFO, which is set
61 automatically by the web server, and GIT_PROJECT_ROOT, which must be set
62 manually in the web server configuration.  If GIT_PROJECT_ROOT is not
63 set, 'git http-backend' reads PATH_TRANSLATED, which is also set
64 automatically by the web server.
66 EXAMPLES
67 --------
68 All of the following examples map 'http://$hostname/git/foo/bar.git'
69 to '/var/www/git/foo/bar.git'.
71 Apache 2.x::
72         Ensure mod_cgi, mod_alias, and mod_env are enabled, set
73         GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and
74         create a ScriptAlias to the CGI:
76 ----------------------------------------------------------------
77 SetEnv GIT_PROJECT_ROOT /var/www/git
78 SetEnv GIT_HTTP_EXPORT_ALL
79 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
80 ----------------------------------------------------------------
82 To enable anonymous read access but authenticated write access,
83 require authorization with a LocationMatch directive:
85 ----------------------------------------------------------------
86 <LocationMatch "^/git/.*/git-receive-pack$">
87         AuthType Basic
88         AuthName "Git Access"
89         Require group committers
90         ...
91 </LocationMatch>
92 ----------------------------------------------------------------
94 In this mode, the server will not request authentication until the
95 client actually starts the object negotiation phase of the push, rather
96 than during the initial contact.  For this reason, you must also enable
97 the `http.receivepack` config option in any repositories that should
98 accept a push. The default behavior, if `http.receivepack` is not set,
99 is to reject any pushes by unauthenticated users; the initial request
100 will therefore report `403 Forbidden` to the client, without even giving
101 an opportunity for authentication.
103 To require authentication for both reads and writes, use a Location
104 directive around the repository, or one of its parent directories:
106 ----------------------------------------------------------------
107 <Location /git/private>
108         AuthType Basic
109         AuthName "Private Git Access"
110         Require group committers
111         ...
112 </Location>
113 ----------------------------------------------------------------
115 To serve gitweb at the same url, use a ScriptAliasMatch to only
116 those URLs that 'git http-backend' can handle, and forward the
117 rest to gitweb:
119 ----------------------------------------------------------------
120 ScriptAliasMatch \
121         "(?x)^/git/(.*/(HEAD | \
122                         info/refs | \
123                         objects/(info/[^/]+ | \
124                                  [0-9a-f]{2}/[0-9a-f]{38} | \
125                                  pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
126                         git-(upload|receive)-pack))$" \
127         /usr/libexec/git-core/git-http-backend/$1
129 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
130 ----------------------------------------------------------------
132 To serve multiple repositories from different linkgit:gitnamespaces[7] in a
133 single repository:
135 ----------------------------------------------------------------
136 SetEnvIf Request_URI "^/git/([^/]*)" GIT_NAMESPACE=$1
137 ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1
138 ----------------------------------------------------------------
140 Accelerated static Apache 2.x::
141         Similar to the above, but Apache can be used to return static
142         files that are stored on disk.  On many systems this may
143         be more efficient as Apache can ask the kernel to copy the
144         file contents from the file system directly to the network:
146 ----------------------------------------------------------------
147 SetEnv GIT_PROJECT_ROOT /var/www/git
149 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1
150 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
151 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
152 ----------------------------------------------------------------
154 This can be combined with the gitweb configuration:
156 ----------------------------------------------------------------
157 SetEnv GIT_PROJECT_ROOT /var/www/git
159 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /var/www/git/$1
160 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
161 ScriptAliasMatch \
162         "(?x)^/git/(.*/(HEAD | \
163                         info/refs | \
164                         objects/info/[^/]+ | \
165                         git-(upload|receive)-pack))$" \
166         /usr/libexec/git-core/git-http-backend/$1
167 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
168 ----------------------------------------------------------------
170 Lighttpd::
171         Ensure that `mod_cgi`, `mod_alias`, `mod_auth`, `mod_setenv` are
172         loaded, then set `GIT_PROJECT_ROOT` appropriately and redirect
173         all requests to the CGI:
175 ----------------------------------------------------------------
176 alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" )
177 $HTTP["url"] =~ "^/git" {
178         cgi.assign = ("" => "")
179         setenv.add-environment = (
180                 "GIT_PROJECT_ROOT" => "/var/www/git",
181                 "GIT_HTTP_EXPORT_ALL" => ""
182         )
184 ----------------------------------------------------------------
186 To enable anonymous read access but authenticated write access:
188 ----------------------------------------------------------------
189 $HTTP["querystring"] =~ "service=git-receive-pack" {
190         include "git-auth.conf"
192 $HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
193         include "git-auth.conf"
195 ----------------------------------------------------------------
197 where `git-auth.conf` looks something like:
199 ----------------------------------------------------------------
200 auth.require = (
201         "/" => (
202                 "method" => "basic",
203                 "realm" => "Git Access",
204                 "require" => "valid-user"
205                )
207 # ...and set up auth.backend here
208 ----------------------------------------------------------------
210 Note that unlike the similar setup with Apache, we can easily match the
211 query string for receive-pack, catching the initial request from the
212 client. This means that the server administrator does not have to worry
213 about configuring `http.receivepack` for the repositories (the default
214 value, which enables it only in the case of authentication, is
215 sufficient).
217 To require authentication for both reads and writes:
219 ----------------------------------------------------------------
220 $HTTP["url"] =~ "^/git/private" {
221         include "git-auth.conf"
223 ----------------------------------------------------------------
226 ENVIRONMENT
227 -----------
228 'git http-backend' relies upon the CGI environment variables set
229 by the invoking web server, including:
231 * PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
232 * REMOTE_USER
233 * REMOTE_ADDR
234 * CONTENT_TYPE
235 * QUERY_STRING
236 * REQUEST_METHOD
238 The GIT_HTTP_EXPORT_ALL environmental variable may be passed to
239 'git-http-backend' to bypass the check for the "git-daemon-export-ok"
240 file in each repository before allowing export of that repository.
242 The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
243 GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
244 ensuring that any reflogs created by 'git-receive-pack' contain some
245 identifying information of the remote user who performed the push.
247 All CGI environment variables are available to each of the hooks
248 invoked by the 'git-receive-pack'.
250 Author
251 ------
252 Written by Shawn O. Pearce <spearce@spearce.org>.
254 Documentation
255 --------------
256 Documentation by Shawn O. Pearce <spearce@spearce.org>.
260 Part of the linkgit:git[1] suite