My .gitignore Trick for Drupal Using Multi-site

I'm always tweaking my Git setup in search of version control nirvana. One thing I've been doing over the past several months makes use of .gitignore and Drupal's multisite feature. The default .gitignore for Drupal 7 looks like this:

# Ignore configuration files that may contain sensitive information.

# Ignore paths that contain user-generated content.

It wisely avoids committing the settings.php files to the repository. (Imagine having to explain how you made your database password publicly available on Github.) Say I was working on with some other developers. My sites folder would look something like this:

  |  + settings.php
  + default
     + files
        + ...

The settings for the production database are in sites/ The way that the multisite feature works is this: any visit to the site at or, or even will use the settings file sites/ It does simple pattern matching so that any URL ending in will first look for settings in the directory of the same name.

My Trick

My trick is simple: add a new sites directory for my local development environment. This will allow separate settings for my development environment. I work on a local site "" running on MAMP or Vagrant, so I add a directory sites/ It would look like this:

  |  + settings.php
  + default
  |  + files
  |     + ...
     + .gitignore
     + settings.php

The .gitignore file contains just one line:


IE. Git will ignore the folder itself and everything in it. This way, none of the other developers would need to know about or any of my local settings.


I used to name my development server something like cleaver.local. On OSX, some time around Lion, the .local suffix started having special meaning and could cause timeouts and delays in loading the page. I switched to .dev and saved two keystrokes every time.