Installing GIT and GITOLITE on CentOS 6

I am using git for a while now. But I am accessing it over SSH without any management. This is enough till you want others to have access to your repositories.

On my server I use a common directory /srv for all server applications, i.e. mysql, postgress, apache, … This is because I am mounting the /srv directory from a NAS server so all the data are in one place. So in this example the home for GIT will be /srv/git. You may want to adjust the script to your own needs.

I am also assuming you have a ssh key. So transfer the public part to the server somewhere, where it will be readable by the created git user.

On the server (CentOS 6):

$ sudo yum --enablerepo=epel install gitolite
$ mkdir -P /srv/git
$ usermod -d /srv/git gitolite
$ chown gitolite:gitolite /srv/git
$ sudo su - gitolite
$ gl-setup /path/to/admin/ssh/key/id_rsa.pub

On the local machine:

$ cd ~/path/to/workspace
$ git clone ssh://gitolite@SERVER/gitolite-admin.git
$ cd gitolite-admin

Edit conf/gitolite.conf

@admins = root ur_user
@developers = ur_user
@observers = some_user

repo    gitolite-admin
        RW+     =   @admins

repo    testing
        RW+     =   @all
$ git add conf/gitolite.conf
$ git commit -m "Udpate condiguration."
$ git push origin master

Add new repository

@admins = root ur_user
@developers = ur_user
@observers = some_user

repo    gitolite-admin
        RW+     =   @admins

repo    new_repo
        RW+ = @developers
        R = @observers

repo    testing
        RW+     =   @all
$ git add conf/gitolite.conf
$ git commit -m "Add new repo."
$ git push origin master

Leave a Reply

Your email address will not be published. Required fields are marked *