Installing a new Drupal site with Git

If you have many Drupal websites on your server, you might want to use a Git repository to ease the upgrades. There is a Drupal repository on GitHub at https://github.com/drupal/drupal.git that contains all the releases and is up-to-date with the development CVS used at Drupal.

Prerequisites:

  • If you don’t have yet a local Git repository for Drupal on your server, these are the steps to clone one in /var/git/drupal:
    mkdir /var/git
    cd /var/git
    git clone https://github.com/drupal/drupal.git
  • We’ll assume you place your Drupal website in /var/www/$SITE/drupal.

In this article, I’ll show you how to install a new Drupal website from a Git repository. As an example we’ll suppose you want to install a Drupal 6.22 — of course, you should use the latest release for a new installation.

export VERSION=6
export CURRENT_RELEASE=22
export CURRENT=drupal-$VERSION.$CURRENT_RELEASE

Install drupal by cloning the local Git repository (See the prerequisites if you don’t have a local Git repository). The variable $SITE should contain the name of the directory holding your website in /var/www:

export SITE=_name of the website_
mkdir /var/www/$SITE
cd /var/www/$SITE
git clone /var/git/drupal

Now you choose the release of Drupal you want to use (in our example it is 6.22). The nice thing about Git is that your drupal contains all the versions. You use the command “checkout” to select which version to use.

cd drupal
git tag            To list the existing Drupal version
git checkout DRUPAL-$VERSION-$CURRENT_RELEASE

Now, we’ll create a Git branch named after your site that derives from this current release. Because branches are cheap in Git we don’t need to shy away from structuring a nice setup with the original branch “CVS” alongside yours — this might prove handy in the future at upgrade time:

git checkout -b $SITE    This creates the new branch and selects it
git branch          This should list both branches

Now continue the installation by running the installation program from the browser as this is the recommended way for the newer Drupal versions.

When you’re finished, commit your changes and tag this new branch:

cd /var/www/$SITE/drupal
git add .
git commit -m "`eval echo $SITE $CURRENT online`"
git tag -a \
    "$SITE-$CURRENT" -m "`eval echo ${SITE} ${CURRENT}`"      Tagging the new branch
git tag                This will list the tags

You now have a perfect setup for future Drupal upgrades.

Tags:

Add new comment

Wiki Textile Syntax

  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [asp], [linux], [c], [cpp], [c#], [delphi], [dos], [f#], [html], [ini], [java], [javascript], [mysql], [perl], [php], [postgresql], [python], [ruby], [sql], [text], [vb], [xml].
  • You can use Textile markup to format text.
  • Web page addresses and e-mail addresses turn into links automatically.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.