Trevor Oke

3737844653

Setting Up a Git Server on Slicehost

Since my last post I’ve been using git more and more. It really suits the way I work a lot better than subversion. Because of this, I wanted to convert one of my projects from svn to Git. It’s a private project, and while I could pony up the cash and get a paid account on GitHub, I’d rather keep everything on something under my control.

I’ve already moved the main project over to slicehost, and since I’m already paying for the space I thought it would be a great idea to host my repositories there.

It was a hell of a lot easier than I thought it would be.

One of the requirements of the install is that I connect to the git repository over ssh. I’ve got it set up so that my ssh server is listening on port 30000 and it authenticates using a public key. No faffing about with passwords here!

Here’s what I did.

Install Git

The first thing we need to do is install git. I’m using aptitude, so this would be done like this:

1
sudo aptidude install git-core

Now you’re ready to create the actual repository.

Create Your Remote Repository

While still connected to your slice, enter the following. Change anything you need to, of course.

1
mkdir ~/repos/example.git cd ~/repos/example.git git init

It doesn’t really get much easier than that.

1
### Create Your Local Repository

Now we go to work on making the local repsitory. All of this is on your local machine:

1
2
3
4
5
6
7
mkdir example
cd example
git init
touch README
git add README
git commit -m "initial repository import"
git remote add origin ssh://username@yourdomain/example.git

In my case, the ssh section would be:

1
ssh://trevor@66.453.44.xxx:30000/home/trevor/repos/example.git

Push!

Now all you have to do is push your local changes back to the remote server. On your local machine: @ git push origin master @ That’s it. You’re done.

This is mostly based on the commonthread

« Quick Edit in WordPress Nice workaround guys »