Manage your Wordpress source code with Git

, , , , No Comments »

I was just thinking of posting an article about using ReSharper and MbUnit together, but before doing that I was going to make sure the source control of the blog was up to date. Then I thought, hey, why don’t I write about that instead.

So this is about using the new Git fast version control system on Ubuntu Gutsy 7.10. to add version control to your Wordpress installation.

So why bother? Especially if you copy your wordpress structure periodically? Well, obviously you can get by with that or frequently zipping into dated snapshots after you make changes. There are advantages though. Usually you’ll get rid of the oldest zip files because you’ll probably never need them, and you probably won’t be taking a snapshot after every change you make. You’re also missing some nice extras like providing comments about changes you’ve made.

So first you’ll want to install git. One way to do that is sudo apt-get install git, but as various blogs will point out git is being developed pretty actively and the packages typically trail a few versions. Piku describes the steps you would take to install 1.5.5 which is what I did. You can also browse http://kernel.org/pub/software/scm/git/ to see which is the highest available version.

From Piku’s Blog Updating git on ubuntu:

mkdir ~/build
cd ~/build
wget http://kernel.org/pub/software/scm/git/git-1.5.5.1.tar.bz2
sudo apt-get build-dep git-core
tar xjf git-1.5.5.1.tar.bz2
cd git-1.5.5.1/
./configure
make
sudo make install

And now you can git stuff. Next go to your wordpress directory, create a git repository there, and commit the current version of your code.

cd /path/to/your/site/wordpress
git init
git add .
git commit -m "initial import"

That’s it. If you want to ls -la you will see there is now a hidden .git directory inside the wordpress directory. It contains all information you would need to restore all of the contents to this state at any time.

Also assuming your Wordpress directory is being published by something like Apache, you’ll want to adjust the security. The following line will take away any read-only access the www-data Apache user would have by default. If you don’t do this, then you’re probably publishing your repository for the rest of the world to download. Very, very bad since your mysql password is probably in the wp-config.php file.

chmod -R og-rwd .git

You can also check the history with git log, or check to see if any files have been added or modified with git status.

Now whenever you make changes you can update your own private version control system with the following:

git status
git add .
git commit -m "changed blah blah for yadda reasons"
git log

The next thing you’re probably going to want to do is push a copy of this hidden git repository onto another location, or even better onto another machine. You may also have a situation where you will make some local changes and decide you simply want to revert to the most recent commit. At this point I think the responsible thing for me to do is leave you searching the git site itself because I would hate to throw a command-line out there someone with more experience will say is completely wrong.

Ah, what the heck. I’ll throw one out there and hopefully someone who knows what they’re doing will correct it.

git reset --hard will force the current directory to return to the state which was last committed. The exception will be new files that have never been added, but you can git status to see which extra files that would be. If you’re feeling especially brave, or potentially foolish, you could do the following:

sudo rm -rf *
git reset --hard
git status

Of course you’ll want to be absolutely certain your current directory is the correct one. Do a “ls -la” first to make sure there’s the .git folder present before you rm. I’ve verified the “sudo rm -rf *” line will not remove the hidden .git folder at the same time. Still it’s such a scary thing to do I’d recommend just using “git status” and removing the extras after you reset.

(As always any corrections in comments are greatly appreciated.)

Dogs eat cable worth more than they are

, , , , , 6 Comments »

The dogs have once again decided it’s time to prove to us how much we love them. They’ve chosen to do this by destroying a composite cable that connects an iPod to the TV. They do this to make us realize we won’t kill them for doing something like this. I still feel it’s ill advised in my own opinion. Especially since Wishbone and Zu-Zu were essentially free, and even though Piggy technically had a greater retail value I believe he has depreciated considerably over the years. The cable by comparison has only been used once to watch Big Trouble in Little China, making it the most expensive Kurt Russell movie I have ever viewed.

Wishbone was kind enough to avoid making eye contact with the cable when questioned, however as his tail never stopped wagging there’s serious doubt to the sincerity of his remorse. Piggy didn’t seem to grasp the concept that something was amiss. And Zu-zu as always didn’t seem to grasp the concept that the world and events surrounding him in time and space related to him in any significant way.

Read the rest of this entry »

What is Lambda

, , , , No Comments »

Something from a previous post was a very small line of code that looked like it was a code fragment used as an argument to a function call.

cruncher.Expect(x => x.Add(2, 4)).Returns(6);
cruncher.Expect(yyy => yyy.Add(5, 2)).Returns(3);

Which brings us to a fork in the road. Down one path you can say, “Well that’s interesting. Some magic was added to dotnet somewhere along the line I might use here or there,” and down the other path you can say, “Well that’s interesting. What is this doing, and exactly how does it work under the hood, because I’ll probably use this here or there and I want to make sure I’m using the the right tool for the job and I’m using it in the right way.”

Going down either path is fine, but this post is for people who want to go down the second one.

Read the rest of this entry »

Quick shout out to Tim

2 Comments »

I’d like to also give a shout out to Tim regarding the recent Windows Server 2008 post. He has been the canary in the coal mine for running 2k8×64 as a primary development workstation. He’s also getting married soon.

Also on that subject here’s a quick note about an issue you may experience running as a user instead of an administrator. I was having a very difficult time turning on a few user-interface options like showing window contents while resizing. I could enter an administrator password and change the setting just fine but it never seemed to take. Turns out the setting must be per-user and I must have been changing the option for the administrator account because of the impersonation.

The workaround is to make your normal user account a member of the administrators group temporarily, then use it for credentials when prompted to make the change, then remove yourself from the administrators group again.

MoQ library is very cool

, , , , No Comments »

Catching up on assorted geek blogs today I came across a mention of the MoQ library being used for unit testing in the Microsoft MVC development initiative that was updated recently.

Always interested in things that very clever people are talking about I grabbed some source to see how it’s used. It’s an amazing display of simplicity and brilliance.

Read the rest of this entry »

Where’s Lou? Slicehost.

, , , , , , No Comments »

Slicehost

You may have noticed Where’s Lou has changed it’s theme recently and has also gone on a sidebar diet. That’s combined with an update to the current version of Wordpress so the backside is nicer in general and has fixed some editor quirks I’ve been coping with.

But even though there were those improvements I started to experience unexplainable outages where any php file on the entire account would simply not respond. I have more than Where’s Lou running on GoDaddy so it was easy to show it wasn’t a blog specific problem.

So enough was enough! Following a lead from Jamie I took a look at Slicehost. It turned out to be as quick, easy, and cool as he’d implied. There’s a huge clarity of thought in the service they provide, how they sell it to you, and how they explain the way to use it.

Read the rest of this entry »

Windows Server 2008

, , 1 Comment »

Windows Server 2008This is what Vista should have been.

Granted my experience with Vista was limited to a notebook which ran it for a few weeks before re-installing with server 2003. Over the years working with internet properties served on Microsoft platforms I’ve always had the best luck running the same operating system on my workstation as is running in production. You learn the quirks, which helps you design and troubleshoot, and you’re also eliminating differences between your development environment and your production environment, which helps smooth out the surprises that pop up during releases.

So I more or less have gone from windows server 2003 to windows server 2008 on my development workstation. I have to say I love everything about it so far.

Read the rest of this entry »

Linq for ActiveRecord

, , , No Comments »

Another topic which is near and dear to my heart is database access technology. Linq for SQL for example is very interesting, almost too interesting. :) One of the problems is that it can be used as an argument against using the ActiveRecord or NHibernate libraries you may already be taking advantage of in your Castle Project based solutions.

So I was delighted to see some posts relating to this topic from Ayende Rahien and Ken Egozi. Based on their excellent work it was simple to construct a Castle.ActiveRecord.Linq library which allowed you to build Linq expressions against a set of ActiveRecord classes as easily as you can build them against a set of Sql DataContext classes.

And all due respect to Microsoft, the designer of their data context still leaves a little to be desired as far as reducing the effort it takes to make tables based on fairly standard assumptions. Yes, it is graphical, but in a basic primary-key one-to-many relationship I was still left manually adding and configuring all of the properties of the columns. And still manually selecting which columns are involved on either side of the relationship.

They’re making great strides but the convention-over-configuration philosophy needs to sink in a little deeper.

And I do agree with Ayende’s when he said, “Of course, I still think that who ever designed Linq was mad.” One of the things that bothers me the most is how it could lead you down a path that returns to the days where you had raw SQL statements distributed throughout your software.

But it is cool.

Castle.Facilities.WorkflowIntegration

, , , , No Comments »

If you create software and need to perform durable processing of long-running activities, one of the things you can use is the Workflow Foundation libraries from Microsoft.

And if you’re using Castle Project you might want to take a look at the workflow integration facility. It’s recently had a demo website added to the solution, and documentation has been built up on the Castle Project wiki.

Putting it together was a very gratifying experience. Hopefully there are some people out in the world that will find such a thing useful. :)

Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in