If you’re using git, you’re sure to know about .gitignore files. They’re used for ignoring certain files (or patterns) from git versioning.

This is really useful if you want to ignore byproducts of your code that shouldn’t be checked in. Common candidates are build/ or dist/ directories but its also very common to see things like coverage/ or *.gem in this list.

There is another type of file you’ll commonly want to ignore though, and these files tend to be environment-specific. Some examples are:

  • vim swap files, *.swo and *.swp
  • emacs swap files ~* or .#*
  • files like nbproject.xml for Netbeans, or equivelant for other environments

We don’t want these in .gitignore, since they are not specific to development with this project, but rather with your specific environment. They shouldn’t crowd up .gitignore for people that don’t have those byproducts in their environment.

Luckily, there’s another file - .git/info/exclude for these types of patterns / files. It works very similarly, but doesn’t get checked in. Use it for any byproducts your environment leaves behind that have nothing to do with your project or its build process.