.hgignore whole directory tree excepting one specific file

John Mee picture John Mee · Nov 5, 2009 · Viewed 8.1k times · Source

Can anyone tell me the .hgignore pattern to track one specific file in a directory and to ignore everything else?

I have a "media" directory which contains a "default.png", for obvious purposes, and the rest of the directory will hold user media. We want hg to ignore everything in the media directory excepting the default file.

Answer

Ry4an Brase picture Ry4an Brase · Nov 5, 2009

Try:

syntax: regex
^media/.*

or (leave it in the default glob and do)

media/**

and then manually hg add media/default.png.

In mercurial (unlike in CVS) you can add files that match your ignore patterns and they work fine. So ignore broadly and hg add what you want tracked.