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