Radio Ramblings

Musings of an amateur nature

Radio Ramblings header image 2

Keeping Wordpress up to date using Git

April 27th, 2008 · 2 Comments

I use Wordpress to manage a couple of sites all on the same server. As a matter of course I’ve set the directories up as Git repositories so that I can easily see if anything has been changed when I don’t expect it (for example, if someone has exploited a vulnerability.)

For those who don’t know, Git is a source code manager.  The purpose of it is to allow teams to work together on writing software, and let them edit the same files at the same time without a problem.  They also include tracking of what has changed in the files.

To make my life easier, I’ve also got the wordpress codebase in a separate directory. I started with version 2.5, so at the time I did:

cd /var/www
wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
cd wordpress
git init
git add -a
git commit -a -m “Wordpress 2.5″

I then set a site up by doing:

mkdir /var/www/md1clv.com
cd /var/www/md1clv.com
git init
git pull ../wordpress

I follow the procedure for setting up a new Wordpress site, and then commit all the changes.

Today I noticed that Wordpress 2.5.1 had been released. Upgrading is pure simplicity - I just need to do:

cd /var/www/wordpress
rm -r *
cd ..
wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
cd wordpress
# Check whether any new files have been added:
git status
# If so add them with “git add”
git commit -a -m “Wordpress 2.5.1″

Then for each site I just need to go into the site’s directory and run “git pull ../wordpress” then visit the upgrade.php page to complete the upgrade.

I love things that make my life simple!

(The next step to make things even simpler will be to find a Git repository of the Wordpress code, and pull from that instead of my own local wordpress directory.)

Tags: Not Radio

2 responses so far ↓

  • 1 Rob Olson // Jul 23, 2008 at 8:28 am

    What did you do about conflicts? When I try to pull from ../wordpress I get a ton of conflicts between the two versions (2.5.1 and 2.6) and I am not going to resolve them myself.

    How did you handle this?

  • 2 Dan // Jul 24, 2008 at 9:03 am

    I’d guess that you have a few plugins installed. I’ve just gone from 2.5.1 to 2.6 on a few sites - some worked without any conflict, but the ones with Akismet installed had an easily merged conflict.

    It might be best to install plugins to the central Wordpress directory, and then “git pull” them into the individual sites. I’ll do some playing later and see what works best.

    Dan

Leave a Comment