.gitignore mistake that everyone makes

.gitignore should be a whitelist, not a blacklist of files you want to include.

If we look at a bunch of random open-source projects, they all instead try to exclude every known undesirable file, e.g.

This setup means that whenever a new developer joins the team or a new tool is adopted by someone in a team, you need to update .gitignore configuration.

A better solution is “ignore everything with exclusions”. In practice, this means that you ignore all files (or at least all hidden files) by default and add exceptions to those files that were agreed to be added to the project, e.g.

In this project we are ignoring all files that start with a dot, but we’ve added exceptions to the configuration files that belong to the project.

This configuration also ensures that you do not accidentally commit private files (keys) that are conventionally prefixed with a dot too.

Adopting this convention will save back-and-forth discussing what exclusions should be added to .gitignore.

Tech / Product Founder — building https://contra.com/