Select Page

GitIgnore

The “.gitignore” file is used to exclude files or folders that are not to be tracked by the version control system. It is important to get it right and to constantly monitor the status of untracked files, tweaking the “.gitignore” file so that nothing unnecessary creeps into a commit.

General Considerations

There are few general considerations for “.gitignore” files, that should be present in most projects.

  • Temporary files: Some programs create temporary files that sometimes get left on disc. Common extensions for these such as *.swp and *.bak can be excluded.
  • Editor files: Other editors create entire folders of project settings. Keep an eye out for these, normally beginning with “.”, so not actually visible to Finder.
  • Resource folders: Directories that contain images or other resources that are uploaded as part of the content of the site. Folders that include “furniture” for the site, such as logos and buttons are fine.
  • .htaccess: This file is almost always different between live and test environments, so should be excluded.

WordPress Considerations

There a few things, specific to WordPress that should normally be in the “.gitignore” file.

  • wp-config.php: The WordPress configuration file will differ between environments. To avoid overwriting it by accident, ignore it and set it up from scratch each time the repo is cloned.
  • wp-content/uploads: This is the main WordPress “resource” folder. See the point on resource folders above. Be aware that some plugins do not use this folder for their resources and can upload large amounts of data to other folders (cForms is particularly bad for this).
  • Default themes: The default themes such as “twentyten” and “twentyeleven” can be ignored. We don’t extend either of these themes, so there’s no need for them to be under version control.
  • hello.php: Ignore the default “Hello Dolly” plugin – it’s pointless.