Trouble un-ignoring previously ignored files in Git repo

We had a very similar problem in our Drupal sites directory. The issue is that the Drupal distribution has a .gitignore file in the higher level drupal directory that matches anything in drupal/sites/files/*


You know how to do it already. Yes, git add -f is the way.

If you ask why... this is because git set a assume-unchanged bit internally. This bit make git think the file is not modified, so git add won't add it.

If you want to mess with the implementation details, you can use git update-index --no-assume-unchanged <file> command.


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.


I don't think J-16 is correct. From http://www.kernel.org/pub/software/scm/git/docs/git-add.html:

The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option.

git add -f seems to only be for adding a file that does exist in an ignore file somewhere.

Perhaps there is another .gitignore file in /sites or /sites/default which is also telling Git to ignore this dir, or maybe it's been set in .git/info/exclude?

Tags:

Git

Gitignore