I cannot get git to unignore a subdirectory even after excluding it in gitignore

In my .gitignore file, I ignored a directory like this:

var

Then I realized that I want to track var/package and all its contents. So, I added that exception for gitignore. I tried many combinations, but decided it was logical, especially from the other discussions here .

 !var/ var/* !var/package !var/package/ !var/package/* 

But when new files are written to var/package , they are not detected. They are added if I use them on purpose, but not through regular procedures like git add .

Is there some kind of command I have to issue on reset .gitignore in order to finally get new gitignore instructions? Did I miss something?

+4
source share
1 answer

Remove anything about var from .gitignore. Create var / .gitignore with the contents:

 /* !/package 

You will obviously need git add -f var/.gitignore , but after that everything should be fine.

another option, at the top level .gitignore, say:

 /var/* !/var/package 

If you are not working, type find . -name .gitignore | xargs egrep . find . -name .gitignore | xargs egrep . and cat .git/info/exclude and tell us what it returns.

+8
source

All Articles