Neil Traft
Neil Traft

Reputation: 19676

Gitignore a nested directory structure anywhere in my repository

Pretty sure no one's asked about this exact pattern yet...

I have some (untracked) auto-generated config files that I'm trying to ignore:

?? PanDA/dp_ptu/cfg/cpp/
?? RCMB/cfg/cpp/

(The cpp/ folder is auto-generated but there are other files inside cfg/ that need to be committed.) So I've entered the following in my .gitignore:

cfg/cpp/

But it doesn't work. This does work:

*/*/cfg/cpp/
*/cfg/cpp/

Obviously that stinks because I need a new entry for every cpp directory. This also works:

cpp/

But I might want to have a cpp folder elsewhere in the repository so I'd really like to avoid doing this. Is there another way?

Upvotes: 0

Views: 3284

Answers (1)

Landys
Landys

Reputation: 7727

**/cfg/cpp/

works for me. Or you may try to put it into .git/info/exclude. Seems no other way if **is ignored in your environment.

Upvotes: 3

Related Questions