Installing a git server using gitosis
I’m switching all my personal projects to git from Subversion. After watching the Peepcode git screencast, Subversion feels oh-so-2002 and I can’t wait to bury it forever.
First we have to get git running on my Ubuntu server. I tried
sudo apt-get install git-core #do not do this!
but that led to trouble down the line. Better to just fetch the source and build from that:
sudo apt-get install libexpat1-dev zlibc curl gettext
cd ~/src
wget http://www.kernel.org/pub/software/scm/git/git-1.5.4.rc2.tar.gz
cd git-1.5.4.rc2
make prefix=/usr/local all
sudo make prefix=/usr/local install
Then, following the excellent instructions on scie.nti.st, we grab the gitosis code:
cd ~/src
git clone git://eagain.net/gitosis.git
Then:
cd gitosis
sudo apt-get install python-setuptools
python setup.py install
Next we have to create a git user to own the repositories:
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
We copy my public ssh key into /tmp/id_rsa.pub, then run
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
And that’s the end of the server-side setup! On the local machine, we check out the files that are needed to control the server. First we have to account for the fact that I run SSH on a nonstandard port: edit ~/.ssh/config and put this inside:
Host www.example.com
Port 32767
Then you can do:
git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
cd gitosis-admin
This is the directory where you administer gitosis.
Comments
A look into it's source and I couldn't sleep for a week, because of the nightmares. Overhyped piece of shit, apparently.
But all the cool kids are using it, so you shouldn't miss it. How would using subversion, cvs, darcs look in oh-so-2008? What would your fun friends would say? How could you socialize with them?
They would cast you out and hate you until the end of time.
You are a fucking hypemonger, go and diaf. You would save the world a lot of trouble.
Anonymous, maybe you're easily intimidated. Git works very well, even if you don't like looking at bash code. If you actually like branching and merging in Subversion, you must like pain.
Nice one. :)
Any comments on setting up a windows client?
You would think that your typical Youtube commenter wouldn't stray from their home site, but then here comes Anon 17:46. "Go and diaf"? In response to some instructions on how to set up a freakin' SCM program? Grow up and look into some anger management therapy. You sound ignorant and unstable.
That said... thank you very much for writing this up. It worked well for me except for about 6 other packages that I hadn't already installed on the very-barebones system I was working on. Once I got those dependencies taken care of, all was well.
Thanks!
I used these instructions to install with git 1.5.6 - don't forget to run ./configure before the make, make install of the git compilation process and make sure /usr/local/bin is in your path.
Thanks for the instructions :-)
Thanks for the instructions, very helpful.
I second Wayne, one should run ./configure before the make
Just to reiterate:
git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
is run on your LOCAL workstation, not on the remote gitosis hosting server as some tutorials suggest.
If the git clone command asks you for a password be sure to
sudo tail -f /etc/log/auth.log
on your remote server and if it complains about the git user not being in AllowUsers, remove the AllowUsers from your /etc/ssh/sshd_config or add the git user to AllowUsers. Only the former worked for me but YMMV.
Of course it should be
sudo tail -f /var/log/auth.log
The anonymous poster is a poo head. Git is way cool, our team has been using it for almost 8 months and it is absolutley brilliant.
If you have worked with feature branches in subversion before, you know what I'm talking about when you randomly consider changing careers while doing a subversion merge.
Git merges are incredibly clever. It's almost magic. Seriously. Merging isn't a big deal anymore and we can go work in feature branches without a worry, and have been, for months.
Coupled with GitHub, a 'social geek network of code', it's brilliant. I'm able to publish and work on my libraries and all my developer friends stay up to date with what I'm doing.
Git is great. GitHub makes it even better. Anonymous, you're an arse.
I'm confused, I do the install on gitosis, but how does it start? I later try to connect to the gitosis admin repo, but it says connection refused
What's wrong with installing ubuntu's git-core?
I've used the repo git packages on ubuntu and debian and they work fine. Furthermore, git-1.5.4 is quite old now and so anybody who follows your "build from source" example is doing themselves a disservice. So I really recommend that you recommend installing the package from the repo.
Ugh, if the Ubuntu packages work for you, you are lucky my friend. I've had no such luck recently with most packages I've tried - git-core included. You are correct, however, that git-1.5.4 is a bit old. The current release (as of this post) is 1.6.6 which you can get here:
wget http://www.kernel.org/pub/software/scm/git/git-1.6.6.tar.gz
and untar with:
tar -xzf git-1.6.6.tar.gz
Thanks for the great instructions!
Hey i'm getting this error when running the 'adduser' command:
adduser: unrecognized option --gecos
What's up with that?
Post new comment