Introduction
This guide will describe how to serve git repository on HTTP port using Apache. This should work on any recent Ubuntu or Debian release, I’ve tested it on Ubuntu Server 11.10. I’m setting it up on my local server 192.168.1.20 under git/agilesparkle, so my repository will be available at http://192.168.1.20/git/agilesparkle. I want it to be password protected but with only single user with following credentials: myusername/mypassword.
Server side
I assume you have Apache installed already. Switch to root account so we won’t need to add sudo all the time and install git:
Create directory for your git repository:
Create bare git repository inside and set the rights so Apache has write access:
Enable dav_fs module. This will automatically enable dav module as well:
Configure Apache to serve git repository using dav:
Copy following inside the newly created file:
<Location /git/agilesparkle> DAV on AuthType Basic AuthName "Git" AuthUserFile /etc/apache2/passwd.git Require valid-user </Location>
Create new file with new user and his password:
Restart Apache server
Client side
Clone the repository:
Create sample file and push it into empty repository:
For the following pushes you can simply use:
If you don’t want to be prompted for the password each time and you don’t mind storing it in plain text, edit following file:
and add following:
machine 192.168.1.20 login myusername password mypassword