The function of .hgignore, like its close cousin, .gitignore, is to to allow you to exclude certain files from being tracked by the source control system. Transient or “variable” files like logs, temporary files and user contributed images are top candidates for such treatment.
Fortunately the syntax for .hgignore follows already established conventions. For example, its regular expression method will be familar to those who work with regexes in perl, java and other languages. There are lots of helpful articles on the Internet on the topic, as you can see from this compilation.
Here’s an example from real life:
# Use glob syntax syntax: glob *.log # Switch to regex syntax syntax: regexp storage/views/.+ public/.sass-cache/.+ public/img/profiles/A.+\.jpg public/img/profiles/Z.+\.jpg public/img/thumbnails/A.+\.jpg public/img/thumbnails/Z.+\.jpg public/img/temp/.+