Be specific about files vs folders in gitignore

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the git category.

Last Updated: 2021-05-15

I created a feature of Semicolon&Sons for browsing videos by tags. However when I ran the integration tests on CircleCI, they failed, saying the app/views/tags/show.html.erb file was not present. The weird part was that the file was on my machine.

The issue was that my global gitignore had an entry for ignoring ctag-generated "tags" files.


The way this was expressed had the effect of also ignoring folders named tags - even deeply nested ones. Therefore I needed to modify this gitignore file to allow for folders named tags:


Explanation of what this does:


When writing a gitignore file (or any similar "ignore file"), ask yourself whether what you are adding ignores files - or folders - or both. Do the minimum ignoring you need to.

What's more, be especially careful with respect to global ignore files, since their effects are further reaching and you mightn't remember to inspect this file when debugging.