I'm trying to get git to ignore the entire packages directory except for .targets files inside it, wherever they may be. I'm trying this in .gitignore but git still ignores the entire packages dir despite the presence of .targets files:
/packages/*
!/packages/**/*.targets
I've also tried following advice from another SO question and un-blacklisting directories first but it still didn't work (this time, it just included all of the packages dir again):
/packages/*
!/packages/**/
!/packages/**/*.targets
How can I get this to work?