Setup git on Centos 5.3, Centos 5.4 and make public over ssh

update oct 22. 2009: This method also works in Centos 5.4. I’ll post the epel think below once they’re available

I setup git on a Centos 5.3 server the other day, accessible over ssh. Here are the steps I followed to get things up and running.

Centos’s yum repository does not have git in it, so setup fedoras epel (Extra Packages for Enterprise Linux) repo.

i386:

    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

x86_64:

    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm

As root run this command:

    yum install git

Next I’m going to setup a new repository and make it accessible over ssh:

    mdkir /home/username/repo #create directory for new repository

    cd /home/username/repo

    git init

We’ll create a dummy file to get started. If you trying to clone (checkout) an empty git repository, you’ll just get errors:

    touch firstfile

Add all files in this directory to your git repository:

    git add .

Commit the changes you’ve made to the repo:

    git commit

Next we’ll create a clone of the repo and configure it to be public:

    cd /home/username

    git clone --bare ./repo repo.git

    touch  repo.git/git-daemon-export-ok

you can copy your repo.git directory to where you want to make the repo public

Now we want to checkout a copy of the new repository from a different server.

    git clone ssh://yourserveraddress/home/username/repo.git

You should now have a new directory labeled repo which contains the file ‘firstfile’

To add a new file to the repo:

    cd repo

    touch secondfile

    git add .

    git commit

Now we want to submit the changes back to the git server:

    git push

You’ll be prompted for your password.

Enjoy.

Add post to:   Delicious Reddit Slashdot Digg Technorati Google
Make comment

Pingbacks

3.01.2010 6:39 Building a deployment server on SliceHost Centos 5.3 « Black Bag Operations Network @www.blackbagops.net
Getting git installed and setup was straightforward and mostly works thanks to this handy guide. I haven’t set up the auth bit but I can at least sync my project to my development area on my laptop.

Comments

avatar

Thanks a lot for your post. After trying all methods, finally I tried yours and it worked. I dont know why installing it in CentOS is such a pain?!?!

avatar

I’m glad this post was helpful. I spent far too long settings up git the first time in CentOS. Thank you EPEL.

Required. 30 chars of fewer.

Required.

captcha image Please, enter symbols, which you see on the image