Tutorial for setting up Git and Gitosis On CentOS 5.2
This article is a tweaked version of several tutorials around. Many of the original links courtesy of Adrian Simmons. Thanks to all the others who gave me loads of help in IRC and thanks to Jerad at Lullabot for inspiring me to dive in to Git with this article.
Before you start, you'll need to install Git (instructions borrowed from this post on How To Linux).
As root, install the dependencies:
yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel gcc
Get the Git source code:
ntar the Git source code:
Untar xvfz git-1.7.1.tar.gz
make prefix=/usr/local all
make prefix=/usr/local install
Then we're in to this Ubuntu article, which I have CentOSified for you. First clone the gitosis repository and run the basic python install. You just need the python setuptools package:
yum install python-setuptools
And then you can easily install Gitosis:
git clone git://eagain.net/gitosis.git
python setup.py install
Next you need to create a user that will own the repositories you want to manage. You can put its home directory wherever you want, but in this example we'll put it in the standard
adduser -r --shell /bin/sh -c 'git version control' --home-dir /home/git git
At this point our Ubuntu instructions lose the plot a bit, but it's ok because I found this CentOS article, which is less clear in some places but explains the SSH bits and onwards far better. It says:
The whole point of Gitosis is to transfer files via ssh using a shared key process (i.e. no password required to login to user Git on your server). Now before you go and start doing it the manual way - don't. Gitosis must create and maintain the authorized_keys file.
So, as your normal user on your local computer (client/development box):
ssh-keygen -t dsa
(I already had one, actually, because I used keys with my old SVN server, so nothing to do here.)
Copy the id_rsa.pub file to the server:
scp ~/.ssh/id_rsa.pub firstname.lastname@example.org:/home/git
As root again and back on the server, gitosis-init is run for the first and only time, loads up your user's key, like this:
su git -c "gitosis-init < /home/git/id_rsa.pub"
Note, because I already had a key set up locally and on the server, I could do this without going to my client machine:
cp /home/myuser/.ssh/authorized_keys /home/git/id_rsa.pub su git -c "gitosis-init < /home/git/id_rsa.pub"
Get rid of the public key we left lying around:
Now we must set some directory and file permissions to let sshd see the new authorized_keys file:
chmod 755 /home/git
chmod 700 /home/git/.ssh
chmod 644 /home/git/.ssh/authorized_keys
Now, back to your local computer, obviously you need to install Git there too. From here on out you can continue with this article from "Step 7 - (On your client)":
Yay! Git on CentOS 5.2.
You're now ready for the big Drupal.org move to Git. =)
Other really useful links include:
http://yehudakatz.com/2010/05/13/common-git-workflows/ (Thanks to Stew Robinson for that one.)
And if you're an SVN user like me: