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
4 <article lang="en" id="git-http-backend(1)">
\r
6 <title>git-http-backend(1)</title>
\r
8 <primary>git-http-backend(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-http-backend - Server side implementation of Git over HTTP</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git http-backend</emphasis></literallayout>
\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
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
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
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
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
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
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
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
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><LocationMatch "^/git/.*/git-receive-pack$">
\r
117 AuthName "Git Access"
\r
118 Require group committers
\r
120 </LocationMatch></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><Location /git/private>
\r
125 AuthName "Private Git Access"
\r
126 Require group committers
\r
128 </Location></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
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
150 Accelerated static Apache 2.x
\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
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
170 "(?x)^/git/(.*/(HEAD | \
\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
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
187 PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
\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
226 <simplesect id="_author">
\r
227 <title>Author</title>
\r
228 <simpara>Written by Shawn O. Pearce <<ulink url="mailto:spearce@spearce.org">spearce@spearce.org</ulink>>.</simpara>
\r
230 <simplesect id="_documentation">
\r
231 <title>Documentation</title>
\r
232 <simpara>Documentation by Shawn O. Pearce <<ulink url="mailto:spearce@spearce.org">spearce@spearce.org</ulink>>.</simpara>
\r
234 <simplesect id="_git">
\r
236 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r