Search code examples
gitgitignore

How to Ignore only subfolders within a Given folder


Suppose my Code Base is like this:

├── index.php
├── _application
|   ├── controllers
|   └── Views
└── _jobs
    ├── report.js
    ├── report.html
    ├──_foo
    |  ├──001....
    |  ├──002....
    └──_bar
       ├──001....
       ├──002....

Here foo & bar are folders within the jobs folder, and there could be any number of folders, and I don't know their names in advance.

Using GitIgnore, I want to ignore all folders within 'jobs' folder, but not the files that are present there.

I have looked at How to ignore all subfolders in a folder with .gitignore, but the solution given there ignores the files in the job folder as well.


Solution

  • Add this !/jobs/*.*, it means, don't ignore anything with an extension which means they are files