hgignore: help ignoring all files but certain ones

Jason S picture Jason S · Oct 3, 2009 · Viewed 16.7k times · Source

I need an .hgdontignore file :-) to include certain files and exclude everything else in a directory. Basically I want to include only the .jar files in a particular directory and nothing else. How can I do this? I'm not that skilled in regular expression syntax. Or can I do it with glob syntax? (I prefer that for readability)

Just as an example location, let's say I want to exclude all files under foo/bar/ except for foo/bar/*.jar.

Answer

Ry4an Brase picture Ry4an Brase · Oct 4, 2009

The answer from Michael is a fine one, but another option is to just exclude:

foo/bar/**

and then manually add the .jar files. You can always add files that are excluded by an ignore rule and it overrides the ignore. You just have to remember to add any jars you create in the future.