1HGIGNORE(5) Mercurial Manual HGIGNORE(5)
2
3
4
6 hgignore - syntax for Mercurial ignore files
7
9 The Mercurial system uses a file called .hgignore in the root directory
10 of a repository to control its behavior when it searches for files that
11 it is not currently tracking.
12
14 The working directory of a Mercurial repository will often contain
15 files that should not be tracked by Mercurial. These include backup
16 files created by editors and build products created by compilers.
17 These files can be ignored by listing them in a .hgignore file in the
18 root of the working directory. The .hgignore file must be created manu‐
19 ally. It is typically put under version control, so that the settings
20 will propagate to other repositories with push and pull.
21
22 An untracked file is ignored if its path relative to the repository
23 root directory, or any prefix path of that path, is matched against any
24 pattern in .hgignore.
25
26 For example, say we have an untracked file, file.c, at a/b/file.c
27 inside our repository. Mercurial will ignore file.c if any pattern in
28 .hgignore matches a/b/file.c, a/b or a.
29
30 In addition, a Mercurial configuration file can reference a set of
31 per-user or global ignore files. See the ignore configuration key on
32 the [ui] section of hg help config for details of how to configure
33 these files.
34
35 To control Mercurial's handling of files that it manages, many commands
36 support the -I and -X options; see hg help <command> and hg help pat‐
37 terns for details.
38
39 Files that are already tracked are not affected by .hgignore, even if
40 they appear in .hgignore. An untracked file X can be explicitly added
41 with hg add X, even if X would be excluded by a pattern in .hgignore.
42
44 An ignore file is a plain text file consisting of a list of patterns,
45 with one pattern per line. Empty lines are skipped. The # character is
46 treated as a comment character, and the \ character is treated as an
47 escape character.
48
49 Mercurial supports several pattern syntaxes. The default syntax used is
50 Python/Perl-style regular expressions.
51
52 To change the syntax used, use a line of the following form:
53
54 syntax: NAME
55
56 where NAME is one of the following:
57
58 regexp
59
60 Regular expression, Python/Perl syntax.
61
62 glob
63
64 Shell-style glob.
65
66 The chosen syntax stays in effect when parsing all patterns that fol‐
67 low, until another syntax is selected.
68
69 Neither glob nor regexp patterns are rooted. A glob-syntax pattern of
70 the form *.c will match a file ending in .c in any directory, and a
71 regexp pattern of the form \.c$ will do the same. To root a regexp pat‐
72 tern, start it with ^.
73
74 Subdirectories can have their own .hgignore settings by adding subin‐
75 clude:path/to/subdir/.hgignore to the root .hgignore. See hg help pat‐
76 terns for details on subinclude: and include:.
77
78 Note Patterns specified in other than .hgignore are always rooted.
79 Please see hg help patterns for details.
80
82 Here is an example ignore file.
83
84 # use glob syntax.
85 syntax: glob
86
87 *.elc
88 *.pyc
89 *~
90
91 # switch to regexp syntax.
92 syntax: regexp
93 ^\.pc/
94
96 Vadim Gelfer <vadim.gelfer@gmail.com>
97
98 Mercurial was written by Matt Mackall <mpm@selenic.com>.
99
101 hg(1), hgrc(5)
102
104 This manual page is copyright 2006 Vadim Gelfer. Mercurial is copy‐
105 right 2005-2018 Matt Mackall. Free use of this software is granted
106 under the terms of the GNU General Public License version 2 or any
107 later version.
108
110 Vadim Gelfer <vadim.gelfer@gmail.com>
111
112 Organization: Mercurial
113
114
115
116
117 HGIGNORE(5)