1GIT-HTTP-BACKEND(1) Git Manual GIT-HTTP-BACKEND(1)
2
3
4
6 git-http-backend - Server side implementation of Git over HTTP
7
9 git http-backend
10
11
13 A simple CGI program to serve the contents of a Git repository to Git
14 clients accessing the repository over http:// and https:// protocols.
15 The program supports clients fetching using both the smart HTTP
16 protocol and the backwards-compatible dumb HTTP protocol, as well as
17 clients pushing using the smart HTTP protocol.
18
19 It verifies that the directory has the magic file
20 "git-daemon-export-ok", and it will refuse to export any git directory
21 that hasn’t explicitly been marked for export this way (unless the
22 GIT_HTTP_EXPORT_ALL environmental variable is set).
23
24 By default, only the upload-pack service is enabled, which serves git
25 fetch-pack and git ls-remote clients, which are invoked from git fetch,
26 git pull, and git clone. If the client is authenticated, the
27 receive-pack service is enabled, which serves git send-pack clients,
28 which is invoked from git push.
29
31 These services can be enabled/disabled using the per-repository
32 configuration file:
33
34 http.getanyfile
35 This serves Git clients older than version 1.6.6 that are unable to
36 use the upload pack service. When enabled, clients are able to read
37 any file within the repository, including objects that are no
38 longer reachable from a branch but are still present. It is enabled
39 by default, but a repository can disable it by setting this
40 configuration item to false.
41
42 http.uploadpack
43 This serves git fetch-pack and git ls-remote clients. It is enabled
44 by default, but a repository can disable it by setting this
45 configuration item to false.
46
47 http.receivepack
48 This serves git send-pack clients, allowing push. It is disabled by
49 default for anonymous users, and enabled by default for users
50 authenticated by the web server. It can be disabled by setting this
51 item to false, or enabled for all users, including anonymous users,
52 by setting it to true.
53
55 To determine the location of the repository on disk, git http-backend
56 concatenates the environment variables PATH_INFO, which is set
57 automatically by the web server, and GIT_PROJECT_ROOT, which must be
58 set manually in the web server configuration. If GIT_PROJECT_ROOT is
59 not set, git http-backend reads PATH_TRANSLATED, which is also set
60 automatically by the web server.
61
63 All of the following examples map http://$hostname/git/foo/bar.git to
64 /var/www/git/foo/bar.git.
65
66 Apache 2.x
67 Ensure mod_cgi, mod_alias, and mod_env are enabled, set
68 GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and create a
69 ScriptAlias to the CGI:
70
71 SetEnv GIT_PROJECT_ROOT /var/www/git
72 SetEnv GIT_HTTP_EXPORT_ALL
73 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
74
75 To enable anonymous read access but authenticated write access,
76 require authorization with a LocationMatch directive:
77
78 <LocationMatch "^/git/.*/git-receive-pack$">
79 AuthType Basic
80 AuthName "Git Access"
81 Require group committers
82 ...
83 </LocationMatch>
84
85 To require authentication for both reads and writes, use a Location
86 directive around the repository, or one of its parent directories:
87
88 <Location /git/private>
89 AuthType Basic
90 AuthName "Private Git Access"
91 Require group committers
92 ...
93 </Location>
94
95 To serve gitweb at the same url, use a ScriptAliasMatch to only
96 those URLs that git http-backend can handle, and forward the rest
97 to gitweb:
98
99 ScriptAliasMatch \
100 "(?x)^/git/(.*/(HEAD | \
101 info/refs | \
102 objects/(info/[^/]+ | \
103 [0-9a-f]{2}/[0-9a-f]{38} | \
104 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
105 git-(upload|receive)-pack))$" \
106 /usr/libexec/git-core/git-http-backend/$1
107
108 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
109
110
111 Accelerated static Apache 2.x
112 Similar to the above, but Apache can be used to return static files
113 that are stored on disk. On many systems this may be more efficient
114 as Apache can ask the kernel to copy the file contents from the
115 file system directly to the network:
116
117 SetEnv GIT_PROJECT_ROOT /var/www/git
118
119 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1
120 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
121 ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
122
123 This can be combined with the gitweb configuration:
124
125 SetEnv GIT_PROJECT_ROOT /var/www/git
126
127 AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1
128 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
129 ScriptAliasMatch \
130 "(?x)^/git/(.*/(HEAD | \
131 info/refs | \
132 objects/info/[^/]+ | \
133 git-(upload|receive)-pack))$" \
134 /usr/libexec/git-core/git-http-backend/$1
135 ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
136
137
139 git http-backend relies upon the CGI environment variables set by the
140 invoking web server, including:
141
142 · PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
143
144 · REMOTE_USER
145
146 · REMOTE_ADDR
147
148 · CONTENT_TYPE
149
150 · QUERY_STRING
151
152 · REQUEST_METHOD
153
154 The GIT_HTTP_EXPORT_ALL environmental variable may be passed to
155 git-http-backend to bypass the check for the "git-daemon-export-ok"
156 file in each repository before allowing export of that repository.
157
158 The backend process sets GIT_COMMITTER_NAME to $REMOTE_USER and
159 GIT_COMMITTER_EMAIL to ${REMOTE_USER}@http.${REMOTE_ADDR}, ensuring
160 that any reflogs created by git-receive-pack contain some identifying
161 information of the remote user who performed the push.
162
163 All CGI environment variables are available to each of the hooks
164 invoked by the git-receive-pack.
165
167 Written by Shawn O. Pearce <spearce@spearce.org[1]>.
168
170 Documentation by Shawn O. Pearce <spearce@spearce.org[1]>.
171
173 Part of the git(1) suite
174
176 1. spearce@spearce.org
177 mailto:spearce@spearce.org
178
179
180
181Git 1.7.1 08/16/2017 GIT-HTTP-BACKEND(1)