This post originally featured on the Echo & Co. blog.
UPDATE: See Three Ways to Get Drush on OS X for a newer guide.
At EchoDitto, we’re big fans of Drush. It’s installed on all of our servers and it’s a great way to perform maintenance tasks, download core and modules, and much much more. I’m not a big fan of installing from zip files though, so let’s use git to easily keep our Drush install up to date.
Before the git transition, I would use Subversion to check out the latest drush release somewhere, like /usr/local/drush (on my Mac), using the CVS clone Subversible. Today, however, I noticed that the latest tagged release Subversible has is 4.2, and the Drush project page has 4.4 ready to download. I figured now would be a good time to start using git for this and stop relying on a third-party to provide the code for Subversion.
The commands below will walk through cloning the Drush git repository and then switching to the latest release. I realize the drush self-update will soon make this irrelevant, but this method works today and is a great exercise in learning how Drupal is using git, especially important coming from Subversion.
Clone the repository. It will create the subfolder “drush” from your current working directory:
Use pear to download includes/table.inc. This one-liner will take care of everything for you as long as you have pear installed and are in the new drush directory:
1 2 3 4
At this point you may or may not have a functioning Drush installation, because you’re using the HEAD of the Drush code repository and it might contain broken code. I would recommend switching the checkout to the latest release. We’ll start by viewing all releases:
1 2 3 4 5 6 7 8 9 10
As of this writing, there are over 50 results from this command, but you’ll see the latest is “7.x-4.4”. If we want our local Drush install to be at 4.4, change the checkout:
1 2 3
That’s it! Drush is set up on 4.4:
Let’s say 4.5 is released tomorrow and you want to change your checkout. First you’ll need to update the local git repository:
View the list of tags:
1 2 3 4 5 6 7 8 9 10 11
And switch your checkout to the new release:
git checkout 7.x-4.5
Repeat for future releases, and enjoy! Of course, once drush self-update begins working, that will be the preferred method, but this will work today. Please questions or comments below.