Trouble un-ignoring previously ignored files in Git repo

git, gitignore

Solution

For posterity: the answer to my problem was "just look closer".

@twalberg pointed out, correctly, that there might be a rule I was overlooking in the .gitignore file. The cascading manner in which the .gitignore rules are applied make it easy to exclude files more broadly than intended.

As far as I can tell, the assumptions I was making about how git works were correct. Similarly, my case doesn't seem to support (or disprove) @J-16 SDiZ 's comments on what role the `assume-unchanged` bit may play.

Problem

I have a site that has a `/sites/default/files/` directory where user content is typically kept. Figuring that I don't need to be tracking this stuff, I added /sites/default/files/ to my .gitignore file. Then I discovered that I also wanted to keep some mostly-permanent uploads in that directory as well. Now it makes more sense to track everything in /sites/default/files/ and exclude undesirable subdirectories, instead of doing it the other way around. The problem is that Git won't stop ignoring that directory. I have removed the lines from .gitignore that specify this directory and it won't track it. I have the option to use `git add /sites/default/files/ -f` to force git to track the directory, but I've done that before and it seems messy. If .gitignore no longer specifies that directory as ignored, why would I have to force Git to start tracking those files?

Original source