There are many cases where it’s important to ignore all of the files inside a directory. Generally, files such as uploads, logs, and caches should not be stored in your git repository.
Lets say you want to ignore all of the files in your /logs directory.
You can ignore the entire directory by adding this line to your root .gitignore file:
This works, but it tells git to ignore the directory itself meaning anyone who builds the project in the future will need to manually create the directory.
Instead, you can add a /logs/.gitignore file containing this:
The logs directory will remain in your repo, but all files inside /logs will be ignored. Easy!