]>
Commit | Line | Data |
---|---|---|
2f4038ab SP |
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] | |
0b444cdb | 11 | 'git http-backend' |
2f4038ab SP |
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. | |
b9af4ab3 ML |
17 | The program supports clients fetching using both the smart HTTP protcol |
18 | and the backwards-compatible dumb HTTP protocol, as well as clients | |
19 | pushing using the smart HTTP protocol. | |
2f4038ab | 20 | |
8b2bd7cd TC |
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). | |
25 | ||
2f4038ab | 26 | By default, only the `upload-pack` service is enabled, which serves |
0b444cdb TR |
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'. | |
2f4038ab | 31 | |
556cfa3b SP |
32 | SERVICES |
33 | -------- | |
34 | These services can be enabled/disabled using the per-repository | |
35 | configuration file: | |
36 | ||
5abb013b SP |
37 | http.getanyfile:: |
38 | This serves older Git clients which 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`. | |
44 | ||
556cfa3b | 45 | http.uploadpack:: |
0b444cdb | 46 | This serves 'git fetch-pack' and 'git ls-remote' clients. |
556cfa3b SP |
47 | It is enabled by default, but a repository can disable it |
48 | by setting this configuration item to `false`. | |
49 | ||
50 | http.receivepack:: | |
0b444cdb | 51 | This serves 'git send-pack' clients, allowing push. It is |
556cfa3b SP |
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`. | |
56 | ||
2f4038ab SP |
57 | URL TRANSLATION |
58 | --------------- | |
0b444cdb | 59 | To determine the location of the repository on disk, 'git http-backend' |
917adc03 ML |
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 | |
0b444cdb | 63 | set, 'git http-backend' reads PATH_TRANSLATED, which is also set |
917adc03 | 64 | automatically by the web server. |
2f4038ab SP |
65 | |
66 | EXAMPLES | |
67 | -------- | |
b9af4ab3 ML |
68 | All of the following examples map 'http://$hostname/git/foo/bar.git' |
69 | to '/var/www/git/foo/bar.git'. | |
2f4038ab SP |
70 | |
71 | Apache 2.x:: | |
917adc03 ML |
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: | |
2f4038ab SP |
75 | + |
76 | ---------------------------------------------------------------- | |
917adc03 | 77 | SetEnv GIT_PROJECT_ROOT /var/www/git |
8b2bd7cd | 78 | SetEnv GIT_HTTP_EXPORT_ALL |
917adc03 | 79 | ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ |
2f4038ab SP |
80 | ---------------------------------------------------------------- |
81 | + | |
556cfa3b SP |
82 | To enable anonymous read access but authenticated write access, |
83 | require authorization with a LocationMatch directive: | |
84 | + | |
85 | ---------------------------------------------------------------- | |
f5ba2d18 | 86 | <LocationMatch "^/git/.*/git-receive-pack$"> |
556cfa3b SP |
87 | AuthType Basic |
88 | AuthName "Git Access" | |
89 | Require group committers | |
90 | ... | |
91 | </LocationMatch> | |
92 | ---------------------------------------------------------------- | |
93 | + | |
917adc03 | 94 | To require authentication for both reads and writes, use a Location |
2f4038ab SP |
95 | directive around the repository, or one of its parent directories: |
96 | + | |
97 | ---------------------------------------------------------------- | |
917adc03 | 98 | <Location /git/private> |
2f4038ab SP |
99 | AuthType Basic |
100 | AuthName "Private Git Access" | |
101 | Require group committers | |
102 | ... | |
917adc03 | 103 | </Location> |
2f4038ab | 104 | ---------------------------------------------------------------- |
8127f778 ML |
105 | + |
106 | To serve gitweb at the same url, use a ScriptAliasMatch to only | |
0b444cdb | 107 | those URLs that 'git http-backend' can handle, and forward the |
8127f778 ML |
108 | rest to gitweb: |
109 | + | |
110 | ---------------------------------------------------------------- | |
111 | ScriptAliasMatch \ | |
112 | "(?x)^/git/(.*/(HEAD | \ | |
113 | info/refs | \ | |
114 | objects/(info/[^/]+ | \ | |
115 | [0-9a-f]{2}/[0-9a-f]{38} | \ | |
116 | pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ | |
117 | git-(upload|receive)-pack))$" \ | |
118 | /usr/libexec/git-core/git-http-backend/$1 | |
119 | ||
120 | ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/ | |
121 | ---------------------------------------------------------------- | |
2f4038ab SP |
122 | |
123 | Accelerated static Apache 2.x:: | |
124 | Similar to the above, but Apache can be used to return static | |
125 | files that are stored on disk. On many systems this may | |
126 | be more efficient as Apache can ask the kernel to copy the | |
127 | file contents from the file system directly to the network: | |
128 | + | |
129 | ---------------------------------------------------------------- | |
917adc03 | 130 | SetEnv GIT_PROJECT_ROOT /var/www/git |
2f4038ab | 131 | |
0ebb1fa7 ML |
132 | AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 |
133 | AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 | |
134 | ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ | |
2f4038ab | 135 | ---------------------------------------------------------------- |
8127f778 ML |
136 | + |
137 | This can be combined with the gitweb configuration: | |
138 | + | |
139 | ---------------------------------------------------------------- | |
140 | SetEnv GIT_PROJECT_ROOT /var/www/git | |
141 | ||
142 | AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 | |
143 | AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 | |
144 | ScriptAliasMatch \ | |
145 | "(?x)^/git/(.*/(HEAD | \ | |
146 | info/refs | \ | |
147 | objects/info/[^/]+ | \ | |
148 | git-(upload|receive)-pack))$" \ | |
149 | /usr/libexec/git-core/git-http-backend/$1 | |
150 | ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/ | |
151 | ---------------------------------------------------------------- | |
2f4038ab SP |
152 | |
153 | ||
154 | ENVIRONMENT | |
155 | ----------- | |
0b444cdb | 156 | 'git http-backend' relies upon the CGI environment variables set |
2f4038ab SP |
157 | by the invoking web server, including: |
158 | ||
917adc03 | 159 | * PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED) |
2f4038ab SP |
160 | * REMOTE_USER |
161 | * REMOTE_ADDR | |
162 | * CONTENT_TYPE | |
163 | * QUERY_STRING | |
164 | * REQUEST_METHOD | |
165 | ||
8b2bd7cd TC |
166 | The GIT_HTTP_EXPORT_ALL environmental variable may be passed to |
167 | 'git-http-backend' to bypass the check for the "git-daemon-export-ok" | |
168 | file in each repository before allowing export of that repository. | |
169 | ||
556cfa3b SP |
170 | The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and |
171 | GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}', | |
172 | ensuring that any reflogs created by 'git-receive-pack' contain some | |
173 | identifying information of the remote user who performed the push. | |
174 | ||
175 | All CGI environment variables are available to each of the hooks | |
176 | invoked by the 'git-receive-pack'. | |
177 | ||
2f4038ab SP |
178 | Author |
179 | ------ | |
180 | Written by Shawn O. Pearce <spearce@spearce.org>. | |
181 | ||
182 | Documentation | |
183 | -------------- | |
184 | Documentation by Shawn O. Pearce <spearce@spearce.org>. | |
185 | ||
186 | GIT | |
187 | --- | |
188 | Part of the linkgit:git[1] suite |