Friday, October 15, 2010

Install your own git server on Cent OS / RHEL /Fedora

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:
mkdir /home/rajat/repo #create directory for new repository
cd /home/rajat/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/rajat
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/rajat/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.
:)

2 comments:

Amin said...

In your second command you have mdkir. it should be MKDIR. That is all :)

Unknown said...

Done thank you :)