Setting up git over http (Smart HTTP in perticular) has it's caveats I will try to emphesize them as I go along.
Final Goal is to run git over http using git-http-backend (a.k.a smart http) in apposed to using webdav which is also called the dumb-method, webdav was never designed to work with git for the reason that it cannot compress object whilst transporting data between the client and the server hosting git [ there is no real git client – git server so i am not referring to it a such].
Versions used in this setup:
- Ubutnu version 12.04-LTS
- Git version 1.7.9.5
- Apache2 version 2.2.22
1. Install prequirests:
1
|
|
2. Enable apache2 modules and reload apache:
1 2 |
|
3. Create a “site” for git:
let's start with a basic virtual host configuration pointing to gitweb:
vim /etc/apache2/sites-available/git
1 2 3 4 5 6 |
|
Enable CGI on the gitweb directory
1 2 3 4 5 |
|
Enable git clone/push/fetch etc over http:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
The env fcgid modules are exactly for this pupose.
Let's spice it up with good old ACL's [for as you know git doesen't deal with that stuff on it's own …] – you can use BASIC/DIGEST
(I chose digest for it uses an MD5 digest hash and not clear text like BASIC auth)
1 2 3 4 5 6 |
|
Create /var/git/.htpasswd for my users:
1
|
|
Change “hagzag” with your username …
4. Create a “shared”, bare repository + set directory permissions to the apache2 user & group
Side note about shared & bare:
**Shared**: Instead of using default umask git repo will be created with 775 perms
**Bare**: instead of creating GIT_DIR in .git (defult git init behaviour), it will be created in the repository direcotry]
1 2 |
|
5. Configure Git Web, /etc/gitweb.conf
1 2 3 |
|
6. Enable site (apache2):
1
|
|
Which yields:
1 2 3 |
|
7. Test your new git repository
Clone the repo via http:
1 2 3 4 5 |
|
… and yes I know it's empty (i created it :)).
_**Create & Add a file**_:
1 2 3 |
|
Commit a file:
1 2 3 4 |
|
Push it:
1 2 3 4 5 6 7 8 |
|
See it on gitweb:
Pitfalls / Caveats:
- Git directory ownership should be the same user running the httpd / apache2 daemon – if not you will get an error like so:G
1 2 3 4 5 |
|
- fcgid module in apache – if it's missing all the above will not work [same goes for env too but it's enabled by default !]
References:
- Git http backend man page,
- git init man page [bare/shared],
- htdigest,
- gitweb man page