Git and Drupal: my .gitignore file

If you're doing anything more than just experimenting in Drupal, you should be using some sort of version control software. If you haven't already picked a version control system, you should go with Git. Why?

  • is moving to Git
  • Every user on will have a Git sandbox account.
  • Git is widely used in open-source and is growing every day.
  • CVS is yucky.

Git can be used to track everything in your Drupal install directory. Everything. There's probably a few things you'd prefer not to track and that's where you can create a .gitignore file. The .gitignore file simply lists every file, pattern, or directory tree you wish to be ignored by Git. To get started, just create a file in the root of your Drupal install directory and name it .gitignore (with the 'dot' as the first character). For my Drupal development, I use the following:


Here's the rundown by line:

  1. .DS_Store - Finder in OSX can dump this file in your directories. No need to track it. Every instance of .DS_Store in every subdirectory will be ignored.
  2. .buildpath - I use Eclipse and this file is created automatically.
  3. .project - Also created by Eclipse
  4. .settings - Also created by Eclipse
  5. /backup - This folder is created when you use drush to update your site. Git is already tracking all the changes to your files in excruciating detail. No need to track the backup of those files in excruciating detail. Everything in this directory and below is ignored.
  6. /sites/default/files/css - If you have turned on CSS aggregation in you performance settings, Drupal will automatically create aggregate CSS files in this directory. No need to track.
  7. /sites/default/files/js - Similarly, if you have JavaScript aggregation turned on, this is where the files would go.
  8. /sites/default/files/xmlsitemap - Like CSS and JavaScript aggregation, the XML Sitemap module will create a file in this directory. No need to track.
  9. /tmp - The tmp directory is, well... temporary. Ignore!

What else?

I don't have any wildcards in my file, but you could ignore all jpg files with *.jpg. Some people might chose not to do tracking on the entire /sites/default/files directory. For more details on .gitignore, see: