Installing a Git (gitosis) server on CentOS 6.2

After recently changing my personal VPS over from a Ubuntu 11.04 system to a CentOS 6.2 I needed to setup a new git repository server of which I will be using for all of my private git repositories instead of hosting them over at Github, Github is perfect for all my open-source (non-private) project but for my personal/private projects I don’t really want to pay lots of money to Github that to be honest I don’t really have… so this is why I decided to setup my own private git server.

So, I only really had to make a few changes from my original Ubuntu 11.04 guide, which can be found here: http://blog.bobbyallen.me/2011/08/29/installing-a-git-server-on-ubuntu-server-11-04/ so I thought I’d just give a quick list of the commands to install on CentOS 6.2, if you do however want to learn more about what the commands are doing etc. check out the above link 🙂

Lets get going…

Firstly we need to login as ‘root’ and then install a few things on our new CentOS 6.2 server, so let quickly just run..

yum install git python-setuptools

Next, we are going to get ready to download (git clone) gitosis so we can install it, run the following commands:-

mkdir ~/src
cd ~/src
git clone git://github.com/res0nat0r/gitosis.git
cd gitosis
sudo python setup.py install

Now we create our system user..

adduser -r –shell /bin/sh -c ‘git version control’ –home-dir /home/git git

As per my Ubuntu guide, at this point you’ll need to copy up your local PC’s public key file (id_rsa.pub) to the server, for simplicity pop it in /tmp/id_rsa.pub on the server so we can access it easily in the next step.. Now we are going to initialize gitosis and give access to the gitosis-admin repository to your local PC (hence copying up our id_rsa.pub file)

sudo -H -u git gitosis-init < /tmp/id_rsa.pub

You should now see a message like:

Initialized empty Git repository in ./
Initialized empty Git repository in ./

If it complains about the directory not existing, just create like so and then run the gitosis-init command above again..

mkdir -p /home/git/gitosis
chown -R git:git /home/git

Thats it… You should now be able to ‘clone’ the gitosis-admin repository to your local PC so that you can now add and manage your git projects and other users! Please see this article for more detail and how to add new users and create new repositories.

Hope you found this useful 🙂

 

 

One reply on “Installing a Git (gitosis) server on CentOS 6.2”