Git: don't ignore -directory- with a dot in it

I tried this .gitignore file:

* !mydirectory.ext !.gitignore 

But it does not work, everything except gitignore is ignored.

Also tried:

  !\mydirectory\.ext 

A directory requires an extension because its plugin is for the application.

Any workarounds?

+6
source share
2 answers

This kind of whitelist is not easy in git.

Once you ignore the git directory, it will not look inside it and therefore will not check for exceptions inside that directory.

The only way around this is with long include / exclude cascades that are really ugly.

The best way is to think about your problem again and try to solve it without such general exceptions, for example, explicitly ignoring everything that you are sure you do not want.

+2
source

ref

 * !/mydirectory.ext/ !/mydirectory.ext/* !/mydirectory/.ext/ !/mydirectory/.ext/* !.gitignore 

or

 * # ignore all !/.*/ # but not directories which names starting with a dot !/.*/* # and all its contents /.*/*/ # but ignore other directories (which names not starting with a dot) # which results also not tracking its files underneath !/.*/.*/ # but not to subdirectories (which names starts with a dot) !/.*/.*/* # and its contents !/*.*/ # don't ignore directories which names has a dot in it !/*.*/* # and its contents # extend it like with /.*/ !.gitignore 

etc.

+7
source

All Articles