Git Ignore And Attribute Files Performance

How do you organize your .gitignore file(s)?

Previously, I preferred one .gitignore file in the repositorys root for some specific reasons:

  • One place to check for and update

Also, I always added (repository-)absolute paths in favor of relative ones, where ever possible. The reasoning being the theory:

  • Absolute is more specific; relative paths don’t have to be checked for all sub- and sub-sub-folders individually

I now learned that[1], at least for relative paths, using multiple .gitignore files in their respective sub-folders leads to a significant speed increase on operations. This only really matters on rather large repositories, (or) with many ignores – or to the enthusiasts.

For me, this raises a question of preference and initial project setup, a re-evaluation is required. Do I want to use one

.gitignore file on smaller projects for better maintainability, and only separate them when the project gets sufficiently large? Do absolute paths even help? – maybe they are an alternative to separating .gitignore files with relative paths?

Anyway, knowing about this fact is interesting and useful. Webkit separated their .gitignore and .gitattribute files to sub-folders.


[1] I learned about it in a pull-request discussion on the mumble project