.gitignore for Drupal

Banner from git site

I have been doing a lot of work with Drupal sites lately, so I thought it would be helpful to share a .gitignore file that seems to do a good job of keeping my Git repositories free of sensitive information (e.g., the settings.php file!) and clutter.

My friend Todd Woofenden sent this to me, but I’ve made some modifications. There are lots of similar .gitignore files out there (e.g., https://gist.github.com/ckng/33c8a8949115c7259a27cc7f4e938521).

I put this in the site’s root directory:

# Ignore paths that may contain user-generated content.
web/sites/*/files
web/sites/*/private

# IgnoreSettings
web/sites/default/settings.php
web/sites/default/settings.local.php
web/sites/default/~settings.local.php

# Ignore private files if you have moved them outsite of web.
private

# Packages #
############
*.7z
*.dmg
*.gz
*.bz2
*.iso
*.jar
*.rar
*.tar
*.zip
*.tgz

# Logs and databases #
######################
*.log
*.sql

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon

Thumbs.db
._*

# Vim generated files #
######################
*.un~

# SASS #
##########
.sass-cache

Feel free to copy and use this on your own sites.

,