git on shared hosting with git-http-backend

I managed to write the correct .htaccess in order to allow git-http-backend without changing apache main config file. The git-http-backend contains description only of a scenario where you have to change the apache config file.
This was tested on hostmonster, but supposed to work on others like bluehost or dreamhost etc.

First you have to make sure that at least git version 1.6.6 is installed on your system. You may build it yourself. We assume that is installed to

$HOME/system/usr/

Now create a script git-http-backend.sh in the directory

$HOME/public_html/website.com/git/

with the following content:


#!/bin/sh
#first we export the GIT_PROJECT_ROOT
export GIT_PROJECT_ROOT=$HOME/gitprojects/
#and run your git-http-backend
$HOME/system/usr/libexec/git-core/git-http-backend

#uncomment the following line if you want to see environment variable values
#echo $REMOTE_USER $QUERY_STRING $REQUEST_METHOD $PATH_INFO >> $HOME/logs/log

the .htaccess file should contain:

Options +ExecCgi
AuthName "Private Git Access"
AuthType Basic
#you need to add users and passwords to the .htpasswd file
#you have to add the same user and password on the client machine under ~/.netrc
AuthUserFile <<YOUR HOME DIR>>/public_html/website.com/git/.htpasswd
Require valid-user
RewriteEngine on
RewriteBase /git
SetHandler cgi-script
RewriteRule ^([a-zA-Z0-9._]*\.git/(HEAD|info/refs|objects/(info/[^/]+|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))|git-(upload|receive)-pack))$ /git/git-http-backend.sh/$1

note that:
1. <<YOUR HOME DIRE>> needs to be replaced by your home directory (or other folder you have access…)
2. the $HOME/public_html/website/git is the physical address of the website, and $HOME/gitprojects is the directory where you host the projects
3. you will be able now to clone your projects under:

4. do not forget to add a file git-daemon-export-ok in the *.git directory you want to “export”

5. make sure that both on your local computer and on your shared host you have at least git 1.6.6 with curl and expat

git clone http://website.com/git/myproject.git

git-http-backend fight on shared hosting continues

Update:

the solution is there (here : ) : http://www.mobiphil.com/2010/03/git-on-shared-hosting-with-git-http-backend

Unfortunatelly the descriptions found on http://progit.org/2010/03/04/smart-http.html and http://ftp.sunet.se/pub/Linux/kernel.org/software/scm/git/docs/git-http-backend.html DO NOT work on a shared hosting. The apache configuration directives mentioned can be used only inside the global http.conf, but not on per directory .httaccess, where shared hosting users might have access. I will try to hack around to find a solution with rewrite, etc. that could be configured through .htaccess.

git smart http transport

I more than welcome the git smart http transport extension. I was deeply disappointed that my new shared hosting provider does not support webdav, so I could not pull my software there for sharing. An fcgi version of the cgi would me more than welcome, as I am sure that most people will use this on shared hosting, like me.