Git your own server!
With the recent boom of GitHub, there are thousands migrating from old subversion and even cvs servers to git. Surprisingly however, many people would rather pay GitHub to host their site instead of doing it themselves. Well I may be on the git bandwagon, but I am definitely not on the pay-for-git one. I recently setup two git servers (for redundancy). This will be a brief tutorial on getting your own git server running on Debian Etch/Lenny/Sid (or Ubuntu).
First we need to install git. Simple enough with this command:
$ sudo apt-get install git-core git-doc git-svn git-email git-cvs
Now we want to ensure git installed correctly
$ git --version git version 1.5.6.3
If you are running Debian Etch, you need to use the backports-etch repo to install git >= 1.5. Or compile it from source.
Alright then just follow the commands:
$ sudo apt-get install python $ sudo apt-get install python-setuptools
Once those are installed just copy paste the following commands. We are going to use gitosis as a way to manage repositories and git access privileges.
$ git clone git://eagain.net/gitosis $ cd gitosis $ python setup.py install
If you receive any errors from running the setup.py script, ensure you installed all the packages above from apt-get.
$ sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
This will setup all your repositories inside of /home/git, feel free to change this to whatever location you desire. Now thats all done, we just need to get your SSH certificate setup so that you can initialize your gitosis install.
This is how it would be done on OSX (this guide for full info on generating SSH keys). From your local machine, issue this command:
$ scp ~/.ssh/id_rsa.pub yourusername@yourserver:/tmp/
Now to wrap this up quickly, go back to your server and setup the SSH key for the gitosis repo.
$ sudo -H -u git gitosis-init < /tmp/id_rsa.pub
If you get an error on initialization then you do not have git >= 1.5. For the rest of us, now we just need to edit the gitosis repo to add/delete users and git repositories! Issuing a simple git push, will propegate the change. For full information, see the gitosis README.


