blob: f4e0741c115905f61a0e92c5255658f4b8e25711 [file] [log] [blame]
Junio C Hamano3b70d3c2009-11-21 17:37:371git-http-backend(1)
2===================
3
4NAME
5----
6git-http-backend - Server side implementation of Git over HTTP
7
8SYNOPSIS
9--------
10[verse]
Junio C Hamano1aa40d22010-01-21 17:46:4311'git http-backend'
Junio C Hamano3b70d3c2009-11-21 17:37:3712
13DESCRIPTION
14-----------
15A simple CGI program to serve the contents of a Git repository to Git
16clients accessing the repository over http:// and https:// protocols.
Junio C Hamano167b1382010-01-31 23:04:3117The program supports clients fetching using both the smart HTTP protocol
Junio C Hamano3b70d3c2009-11-21 17:37:3718and the backwards-compatible dumb HTTP protocol, as well as clients
19pushing using the smart HTTP protocol.
20
Junio C Hamano6ce6b6c2010-01-18 01:25:5021It verifies that the directory has the magic file
22"git-daemon-export-ok", and it will refuse to export any git directory
23that hasn't explicitly been marked for export this way (unless the
24GIT_HTTP_EXPORT_ALL environmental variable is set).
25
Junio C Hamano3b70d3c2009-11-21 17:37:3726By default, only the `upload-pack` service is enabled, which serves
Junio C Hamano1aa40d22010-01-21 17:46:4327'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,
29the `receive-pack` service is enabled, which serves 'git send-pack'
30clients, which is invoked from 'git push'.
Junio C Hamano3b70d3c2009-11-21 17:37:3731
32SERVICES
33--------
34These services can be enabled/disabled using the per-repository
35configuration file:
36
37http.getanyfile::
Junio C Hamano1f630d52010-04-01 04:49:2538This serves Git clients older than version 1.6.6 that are unable to use the
Junio C Hamano3b70d3c2009-11-21 17:37:3739upload pack service. When enabled, clients are able to read
40any file within the repository, including objects that are
41no longer reachable from a branch but are still present.
42It is enabled by default, but a repository can disable it
43by setting this configuration item to `false`.
44
45http.uploadpack::
Junio C Hamano1aa40d22010-01-21 17:46:4346This serves 'git fetch-pack' and 'git ls-remote' clients.
Junio C Hamano3b70d3c2009-11-21 17:37:3747It is enabled by default, but a repository can disable it
48by setting this configuration item to `false`.
49
50http.receivepack::
Junio C Hamano1aa40d22010-01-21 17:46:4351This serves 'git send-pack' clients, allowing push. It is
Junio C Hamano3b70d3c2009-11-21 17:37:3752disabled by default for anonymous users, and enabled by
53default for users authenticated by the web server. It can be
54disabled by setting this item to `false`, or enabled for all
55users, including anonymous users, by setting it to `true`.
56
57URL TRANSLATION
58---------------
Junio C Hamano1aa40d22010-01-21 17:46:4359To determine the location of the repository on disk, 'git http-backend'
Junio C Hamano3b70d3c2009-11-21 17:37:3760concatenates the environment variables PATH_INFO, which is set
61automatically by the web server, and GIT_PROJECT_ROOT, which must be set
62manually in the web server configuration. If GIT_PROJECT_ROOT is not
Junio C Hamano1aa40d22010-01-21 17:46:4363set, 'git http-backend' reads PATH_TRANSLATED, which is also set
Junio C Hamano3b70d3c2009-11-21 17:37:3764automatically by the web server.
65
66EXAMPLES
67--------
68All of the following examples map 'http://$hostname/git/foo/bar.git'
69to '/var/www/git/foo/bar.git'.
70
71Apache 2.x::
72Ensure mod_cgi, mod_alias, and mod_env are enabled, set
73GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and
74create a ScriptAlias to the CGI:
75+
76----------------------------------------------------------------
77SetEnv GIT_PROJECT_ROOT /var/www/git
Junio C Hamano6ce6b6c2010-01-18 01:25:5078SetEnv GIT_HTTP_EXPORT_ALL
Junio C Hamano3b70d3c2009-11-21 17:37:3779ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
80----------------------------------------------------------------
81+
82To enable anonymous read access but authenticated write access,
83require authorization with a LocationMatch directive:
84+
85----------------------------------------------------------------
86<LocationMatch "^/git/.*/git-receive-pack$">
87AuthType Basic
88AuthName "Git Access"
89Require group committers
90...
91</LocationMatch>
92----------------------------------------------------------------
93+
94To require authentication for both reads and writes, use a Location
95directive around the repository, or one of its parent directories:
96+
97----------------------------------------------------------------
98<Location /git/private>
99AuthType Basic
100AuthName "Private Git Access"
101Require group committers
102...
103</Location>
104----------------------------------------------------------------
105+
106To serve gitweb at the same url, use a ScriptAliasMatch to only
Junio C Hamano1aa40d22010-01-21 17:46:43107those URLs that 'git http-backend' can handle, and forward the
Junio C Hamano3b70d3c2009-11-21 17:37:37108rest to gitweb:
109+
110----------------------------------------------------------------
111ScriptAliasMatch \
112"(?x)^/git/(.*/(HEAD | \
113info/refs | \
114objects/(info/[^/]+ | \
115 [0-9a-f]{2}/[0-9a-f]{38} | \
116 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
117git-(upload|receive)-pack))$" \
118/usr/libexec/git-core/git-http-backend/$1
119
120ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
121----------------------------------------------------------------
Junio C Hamanof7279012011-08-18 06:13:13122+
123To serve multiple repositories from different linkgit:gitnamespaces[7] in a
124single repository:
125+
126----------------------------------------------------------------
127SetEnvIf Request_URI "^/git/([^/]*)" GIT_NAMESPACE=$1
128ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1
129----------------------------------------------------------------
Junio C Hamano3b70d3c2009-11-21 17:37:37130
131Accelerated static Apache 2.x::
132Similar to the above, but Apache can be used to return static
133files that are stored on disk. On many systems this may
134be more efficient as Apache can ask the kernel to copy the
135file contents from the file system directly to the network:
136+
137----------------------------------------------------------------
138SetEnv GIT_PROJECT_ROOT /var/www/git
139
140AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1
141AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
142ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
143----------------------------------------------------------------
144+
145This can be combined with the gitweb configuration:
146+
147----------------------------------------------------------------
148SetEnv GIT_PROJECT_ROOT /var/www/git
149
150AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1
151AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
152ScriptAliasMatch \
153"(?x)^/git/(.*/(HEAD | \
154info/refs | \
155objects/info/[^/]+ | \
156git-(upload|receive)-pack))$" \
157/usr/libexec/git-core/git-http-backend/$1
158ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
159----------------------------------------------------------------
160
161
162ENVIRONMENT
163-----------
Junio C Hamano1aa40d22010-01-21 17:46:43164'git http-backend' relies upon the CGI environment variables set
Junio C Hamano3b70d3c2009-11-21 17:37:37165by the invoking web server, including:
166
167* PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
168* REMOTE_USER
169* REMOTE_ADDR
170* CONTENT_TYPE
171* QUERY_STRING
172* REQUEST_METHOD
173
Junio C Hamano6ce6b6c2010-01-18 01:25:50174The GIT_HTTP_EXPORT_ALL environmental variable may be passed to
175'git-http-backend' to bypass the check for the "git-daemon-export-ok"
176file in each repository before allowing export of that repository.
177
Junio C Hamano3b70d3c2009-11-21 17:37:37178The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
179GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
180ensuring that any reflogs created by 'git-receive-pack' contain some
181identifying information of the remote user who performed the push.
182
183All CGI environment variables are available to each of the hooks
184invoked by the 'git-receive-pack'.
185
186Author
187------
188Written by Shawn O. Pearce <spearce@spearce.org>.
189
190Documentation
191--------------
192Documentation by Shawn O. Pearce <spearce@spearce.org>.
193
194GIT
195---
196Part of the linkgit:git[1] suite