Ignoring a directory ... but not a subdirectory or two

I always thought I knew how to ignore and deny patterns, but I'm at a dead end. I have a basic Drupal installation, and I would like to ignore everything in the sites/ folder, except for a few specific subdirectories: sites/all and sites/my-project .

 .vagrant settings.php # A directory set aside for user contributed assets uploads/ # All we care about is sites/all and sites/my-project www/sites/* !www/sites/all !www/sites/my-project 

Given the above .gitignore file in the root of the project when I do git add . I get everything I expect from www/sites/all , but nothing from www/sites/my-project . What am I missing here? There is only one file that excites me ( www/sites/my-project/settings.sample.php ) right now, but I can’t understand why it is not added like everything else.

I know that I can do this, but I want to understand a more serious problem. What am I missing here? Whatever it costs, this is my initial fixation. I do not understand that this matters, but I also do not know that this is not so.

UPDATE

Oops! It seems that one file that excites me is ignored (which explains why the directory is ignored). I have no idea where or why, but it gives me a place to search ...

+2
source share
1 answer

I do not see the problem:

 $ find . . ./.gitignore ./www ./www/sites ./www/sites/ignored ./www/sites/ignored/file ./www/sites/my-project ./www/sites/my-project/file ./www/sites/my-project/settings.sample.php ./www/sites/all ./www/sites/all/file $ git init Initialized empty Git repository in /home/desert69/tmp/gitignore/.git/ $ cat .gitignore .vagrant settings.php # A directory set aside for user contributed assets uploads/ # All we care about is sites/all and sites/my-project www/sites/* !www/sites/all !www/sites/my-project $ git add . $ git status --short A .gitignore A www/sites/all/file A www/sites/my-project/file A www/sites/my-project/settings.sample.php $ git --version git version 1.7.10.4 

So everything works.

Try rm -rf .git/ && git init in case you previously ignored or added some other file.

I thought that maybe there was something that the dot in settings.php interpreted as * , so it corresponded to .sample. but does not seem.

Try deleting and re-deleting the repository.

0
source

Source: https://habr.com/ru/post/1205311/


All Articles