skip main content

Posts Tagged ‘git’

Setting up your own hosted private Git repository

posted by Duncan at 1:12 pm on May 6th, 2011

Now I’m a fully paid up user of Github. It’s a wonderful service, site and community of developers. But for the account plan I can afford, I only get 5 private repositories. I’m happy to make my work public, but there are some bits of software I want to keep private right now and yet still have remote copies of, and this comes to more that 5. I still want to use Git, and maybe one day make them public on Github. Here’s my solution using my own hosting as a private Git repository and just using Git and SSH to do the job.

Before we start, I’m assuming that you have SSH access to your hosting, and you have Git installed both on your machine and on the host.

First create a folder on your remote machine to hold the repos

$ ssh
$ mkdir git
$ exit

If you have the correct permission or sudo access you could do the same as me and create the dir at /opt/git. You’ll need to replace all other mentions of git with this new path if you go this route.

Navigate to the local git repos on your machine that you want to have a remote copy of. Running the command below will give you a bare copy of the repos in your tmp dir.

$ git clone --bare /path/to/myrepo/.git /tmp/myrepo.git

Now you need to get this copy onto your remote machine. There are various ways but the simplest is scp with the recursive flag set:

$ scp -r /tmp/myrepo.git

You have a couple of choices now. You can either just navigate in into your local git repos and add your remote git as a remote to your config like this:

$ git remote add myserver

or you can delete your old repos and check out the remote one. Make sure you backup the old one until you’re sure it works ok though.

$ git clone

You can now make changes and push them to your new remote repos when ever you want.

Hope this helps someone. It doesn’t solve everything, but is a simple way to have a private alternate copy of your Git repositories.

Deploying WordPress to SliceHost using Capistrano and Git

posted by Duncan at 12:00 pm on February 1st, 2009

Skip straight to the how-to if you don’t care about an introduction.

This post has been in my drafts folder for about 6 months, and I intended to be much more detailed, but I don’t think I’m gonna ever get round to it, so here is the shortened version.

I did a post a while back on how to deploy WordPress to TextDrive using Capistrano, which people seemed to find useful. I still use WordPress, and I still find Capistrano perfect for deployment in this situation. They’re the only two constants though, as I have now changed hosts, changed source control systems, oh and Capistrano has jumped up a major release and many minor releases, so the interface is slightly different.

I moved over to SliceHost because I wanted the control that virtual hosting gives you, and those guys are cheap, as well as having an awesome service thus far.

The actual installation of Apache, MySQL and PHP is quite simple through YUM and well documented via the Slicehost support area so I won’t repeat this. I also moved over to Git a while back, after researching distributed source control systems, and playing with Mercurial for a while. Git just seemed to tick more boxes for my current needs both at work, and home play.

1. Assumptions

I have based the post on the fact I choose to put all the sites I deploy in a my home directory. Some other assumptions are:

  • You have Apache, MySQL and PHP installed
  • You have an account on the machine with sudo access
  • You have a Git installed on the machine you will be deploying from

Now you need to organise your wordpress source into this structure:

    + index.php
    + wp-admin/
    + wp-xxxx
     etc ....

2. Configure Capistrano

You can download my basic Capfile that should help get you started. The only things you will need to change are :domain and :user. For example, for my site I may use:

set :domain, ""
set :user, "websites"

This would mean that I can normally access my server using:


3. Initialise your Git repo

I kind of expect you to have already done this, but if you haven’t, change into the root directory (The one with the Capfile in it) and run:

git init
git add .
git commit -a -m 'initial import into Git'

4. Deploy

You should now have enough initial information to let Capistrano deploy WP to your server. First though, you need to run the Capistrano setup command to stick a bunch of folders on your server ready to hold your site. This is a good test command too as it lets you know if you have setup your :domain and :user ok.

cap deploy:setup

If that went ok, then you can now run the mighty:

cap deploy

That’s it! you should now have your blog deploying to your server.

5. Apache setup

All you need to do now is setup Apache to point to the folder. You can use this vhost file. Rename it and edit it’s contents to suit your site, then stick it in your


folder. Restart Apache:

sudo /sbin/services httpd restart

Now browse to your sites url and to the admin area and setup your blog as per the WordPress instructions. Best of luck!

back to the top