Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.hgignore whole directory tree excepting one specific file

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.

like image 504
John Mee Avatar asked Nov 05 '09 03:11

John Mee


2 Answers

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.

like image 183
Ry4an Brase Avatar answered Oct 02 '22 15:10

Ry4an Brase


syntax: regex
^media/(?!default.png$)

almost the same as John Mee's but matches to the end of the line, instead of anything that starts with default.png.

if you wanted to allow any .c file but nothing else, you could use:

^media/(?!.+\.c$)
like image 35
frankster Avatar answered Oct 02 '22 13:10

frankster