http-backend: add GIT_PROJECT_ROOT environment var
[git] / Documentation / git-http-backend.txt
1 git-http-backend(1)
2 ===================
3
4 NAME
5 ----
6 git-http-backend - Server side implementation of Git over HTTP
7
8 SYNOPSIS
9 --------
10 [verse]
11 'git-http-backend'
12
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
18 By default, only the `upload-pack` service is enabled, which serves
19 'git-fetch-pack' and 'git-ls-remote' clients, which are invoked from
20 'git-fetch', 'git-pull', and 'git-clone'.
21
22 This is ideally suited for read-only updates, i.e., pulling from
23 git repositories.
24
25 SERVICES
26 --------
27 These services can be enabled/disabled using the per-repository
28 configuration file:
29
30 http.uploadpack::
31         This serves 'git-fetch-pack' and 'git-ls-remote' clients.
32         It is enabled by default, but a repository can disable it
33         by setting this configuration item to `false`.
34
35 http.receivepack::
36         This serves 'git-send-pack' clients, allowing push.  It is
37         disabled by default for anonymous users, and enabled by
38         default for users authenticated by the web server.  It can be
39         disabled by setting this item to `false`, or enabled for all
40         users, including anonymous users, by setting it to `true`.
41
42 URL TRANSLATION
43 ---------------
44 To determine the location of the repository on disk, 'git-http-backend'
45 concatenates the environment variables PATH_INFO, which is set
46 automatically by the web server, and GIT_PROJECT_ROOT, which must be set
47 manually in the web server configuration.  If GIT_PROJECT_ROOT is not
48 set, 'git-http-backend' reads PATH_TRANSLATED, which is also set
49 automatically by the web server.
50
51 EXAMPLES
52 --------
53
54 Apache 2.x::
55         Ensure mod_cgi, mod_alias, and mod_env are enabled, set
56         GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and
57         create a ScriptAlias to the CGI:
58 +
59 ----------------------------------------------------------------
60 SetEnv GIT_PROJECT_ROOT /var/www/git
61 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
62 ----------------------------------------------------------------
63 +
64 To enable anonymous read access but authenticated write access,
65 require authorization with a LocationMatch directive:
66 +
67 ----------------------------------------------------------------
68 <LocationMatch ".*/git-receive-pack$">
69         AuthType Basic
70         AuthName "Git Access"
71         Require group committers
72         ...
73 </LocationMatch>
74 ----------------------------------------------------------------
75 +
76 To require authentication for both reads and writes, use a Location
77 directive around the repository, or one of its parent directories:
78 +
79 ----------------------------------------------------------------
80 <Location /git/private>
81         AuthType Basic
82         AuthName "Private Git Access"
83         Require group committers
84         ...
85 </Location>
86 ----------------------------------------------------------------
87
88 Accelerated static Apache 2.x::
89         Similar to the above, but Apache can be used to return static
90         files that are stored on disk.  On many systems this may
91         be more efficient as Apache can ask the kernel to copy the
92         file contents from the file system directly to the network:
93 +
94 ----------------------------------------------------------------
95 SetEnv GIT_PROJECT_ROOT /var/www/git
96
97 ScriptAlias /git/        /usr/libexec/git-core/git-http-backend/
98 Alias       /git_static/ /var/www/git/
99
100 RewriteEngine on
101 RewriteRule ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$    /git_static/$1 [PT]
102 RewriteRule ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.pack)$ /git_static/$1 [PT]
103 RewriteRule ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.idx)$  /git_static/$1 [PT]
104 ----------------------------------------------------------------
105
106
107 ENVIRONMENT
108 -----------
109 'git-http-backend' relies upon the CGI environment variables set
110 by the invoking web server, including:
111
112 * PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
113 * REMOTE_USER
114 * REMOTE_ADDR
115 * CONTENT_TYPE
116 * QUERY_STRING
117 * REQUEST_METHOD
118
119 The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
120 GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
121 ensuring that any reflogs created by 'git-receive-pack' contain some
122 identifying information of the remote user who performed the push.
123
124 All CGI environment variables are available to each of the hooks
125 invoked by the 'git-receive-pack'.
126
127 Author
128 ------
129 Written by Shawn O. Pearce <spearce@spearce.org>.
130
131 Documentation
132 --------------
133 Documentation by Shawn O. Pearce <spearce@spearce.org>.
134
135 GIT
136 ---
137 Part of the linkgit:git[1] suite