Wizard Wizard - 1 year ago 63
Git Question

Git ignore all files in directory but not directory

Now I was added in .gitignore


Now git ignore all cache directory and I can't add this directory to git. Question is how to ignor image/cache/ files but, not directory ?

Answer Source

While the previous answer is pretty correct, this might be helpful:

You can specify a subdirectory of an ignored directory to not be ignored. eg: Ignore cache, but not 'excluded' in cache:


You can also force add ignored files using:

git add path/to/file --force

But as previously stated, this only works on files, not directories.