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 in‐
27 side 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 rootglob
67
68 A variant of glob that is rooted (see below).
69
70 The chosen syntax stays in effect when parsing all patterns that fol‐
71 low, until another syntax is selected.
72
73 Neither glob nor regexp patterns are rooted. A glob-syntax pattern of
74 the form *.c will match a file ending in .c in any directory, and a
75 regexp pattern of the form \.c$ will do the same. To root a regexp pat‐
76 tern, start it with ^. To get the same effect with glob-syntax, you
77 have to use rootglob.
78
79 Subdirectories can have their own .hgignore settings by adding subin‐
80 clude:path/to/subdir/.hgignore to the root .hgignore. See hg help pat‐
81 terns for details on subinclude: and include:.
82
83 Note Patterns specified in other than .hgignore are always rooted.
84 Please see hg help patterns for details.
85
87 Here is an example ignore file.
88
89 # use glob syntax.
90 syntax: glob
91
92 *.elc
93 *.pyc
94 *~
95
96 # switch to regexp syntax.
97 syntax: regexp
98 ^\.pc/
99
101 Use the debugignore command to see if and why a file is ignored, or to
102 see the combined ignore pattern. See hg help debugignore for details.
103
105 Vadim Gelfer <vadim.gelfer@gmail.com>
106
107 Mercurial was written by Olivia Mackall <olivia@selenic.com>.
108
110 hg(1), hgrc(5)
111
113 This manual page is copyright 2006 Vadim Gelfer. Mercurial is copy‐
114 right 2005-2022 Olivia Mackall. Free use of this software is granted
115 under the terms of the GNU General Public License version 2 or any
116 later version.
117
119 Vadim Gelfer <vadim.gelfer@gmail.com>
120
121 Organization: Mercurial
122
123
124
125
126 HGIGNORE(5)