summaryrefslogtreecommitdiff
path: root/doc/hgignore.5.html
blob: d760dbabec83a1109dcf392934fd60bbb13e930b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.8.1: http://docutils.sourceforge.net/" />
<title>hgignore</title>
<meta name="author" content="Vadim Gelfer &lt;vadim.gelfer&#64;gmail.com&gt;" />
<meta name="organization" content="Mercurial" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="document" id="hgignore">
<h1 class="title">hgignore</h1>
<h2 class="subtitle" id="syntax-for-mercurial-ignore-files">syntax for Mercurial ignore files</h2>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Vadim Gelfer &lt;<a class="reference external" href="mailto:vadim.gelfer&#64;gmail.com">vadim.gelfer&#64;gmail.com</a>&gt;</td></tr>
<tr><th class="docinfo-name">Organization:</th>
<td>Mercurial</td></tr>
<tr class="field"><th class="docinfo-name">Manual section:</th><td class="field-body">5</td>
</tr>
<tr class="field"><th class="docinfo-name">Manual group:</th><td class="field-body">Mercurial Manual</td>
</tr>
</tbody>
</table>
<div class="section" id="synopsis">
<h1>Synopsis</h1>
<p>The Mercurial system uses a file called <tt class="docutils literal">.hgignore</tt> in the root
directory of a repository to control its behavior when it searches
for files that it is not currently tracking.</p>
</div>
<div class="section" id="description">
<h1>Description</h1>
<p>The working directory of a Mercurial repository will often contain
files that should not be tracked by Mercurial. These include backup
files created by editors and build products created by compilers.
These files can be ignored by listing them in a <tt class="docutils literal">.hgignore</tt> file in
the root of the working directory. The <tt class="docutils literal">.hgignore</tt> file must be
created manually. It is typically put under version control, so that
the settings will propagate to other repositories with push and pull.</p>
<p>An untracked file is ignored if its path relative to the repository
root directory, or any prefix path of that path, is matched against
any pattern in <tt class="docutils literal">.hgignore</tt>.</p>
<p>For example, say we have an untracked file, <tt class="docutils literal">file.c</tt>, at
<tt class="docutils literal">a/b/file.c</tt> inside our repository. Mercurial will ignore <tt class="docutils literal">file.c</tt>
if any pattern in <tt class="docutils literal">.hgignore</tt> matches <tt class="docutils literal">a/b/file.c</tt>, <tt class="docutils literal">a/b</tt> or <tt class="docutils literal">a</tt>.</p>
<p>In addition, a Mercurial configuration file can reference a set of
per-user or global ignore files. See the <tt class="docutils literal">ignore</tt> configuration
key on the <tt class="docutils literal">[ui]</tt> section of <a class="reference external" href="hg.1.html#config"><tt class="docutils literal">hg help config</tt></a> for details of how to
configure these files.</p>
<p>To control Mercurial's handling of files that it manages, many
commands support the <tt class="docutils literal"><span class="pre">-I</span></tt> and <tt class="docutils literal"><span class="pre">-X</span></tt> options; see
<a class="reference external" href="hg.1.html#&lt;command&gt;"><tt class="docutils literal">hg help &lt;command&gt;</tt></a> and <a class="reference external" href="hg.1.html#patterns"><tt class="docutils literal">hg help patterns</tt></a> for details.</p>
<p>Files that are already tracked are not affected by .hgignore, even
if they appear in .hgignore. An untracked file X can be explicitly
added with <a class="reference external" href="hg.1.html#add"><tt class="docutils literal">hg add X</tt></a>, even if X would be excluded by a pattern
in .hgignore.</p>
</div>
<div class="section" id="syntax">
<h1>Syntax</h1>
<p>An ignore file is a plain text file consisting of a list of patterns,
with one pattern per line. Empty lines are skipped. The <tt class="docutils literal">#</tt>
character is treated as a comment character, and the <tt class="docutils literal">\</tt> character
is treated as an escape character.</p>
<p>Mercurial supports several pattern syntaxes. The default syntax used
is Python/Perl-style regular expressions.</p>
<p>To change the syntax used, use a line of the following form:</p>
<pre class="literal-block">
syntax: NAME
</pre>
<p>where <tt class="docutils literal">NAME</tt> is one of the following:</p>
<dl class="docutils">
<dt><tt class="docutils literal">regexp</tt></dt>
<dd>Regular expression, Python/Perl syntax.</dd>
<dt><tt class="docutils literal">glob</tt></dt>
<dd>Shell-style glob.</dd>
</dl>
<p>The chosen syntax stays in effect when parsing all patterns that
follow, until another syntax is selected.</p>
<p>Neither glob nor regexp patterns are rooted. A glob-syntax pattern of
the form <tt class="docutils literal">*.c</tt> will match a file ending in <tt class="docutils literal">.c</tt> in any directory,
and a regexp pattern of the form <tt class="docutils literal">\.c$</tt> will do the same. To root a
regexp pattern, start it with <tt class="docutils literal">^</tt>.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">Patterns specified in other than <tt class="docutils literal">.hgignore</tt> are always rooted.
Please see <a class="reference external" href="hg.1.html#patterns"><tt class="docutils literal">hg help patterns</tt></a> for details.</p>
</div>
</div>
<div class="section" id="example">
<h1>Example</h1>
<p>Here is an example ignore file.</p>
<pre class="literal-block">
# use glob syntax.
syntax: glob

*.elc
*.pyc
*~

# switch to regexp syntax.
syntax: regexp
^\.pc/
</pre>
</div>
<div class="section" id="author">
<h1>Author</h1>
<p>Vadim Gelfer &lt;<a class="reference external" href="mailto:vadim.gelfer&#64;gmail.com">vadim.gelfer&#64;gmail.com</a>&gt;</p>
<p>Mercurial was written by Matt Mackall &lt;<a class="reference external" href="mailto:mpm&#64;selenic.com">mpm&#64;selenic.com</a>&gt;.</p>
</div>
<div class="section" id="see-also">
<h1>See Also</h1>
<p><a class="reference external" href="hg.1.html"><strong>hg</strong>(1)</a>, <a class="reference external" href="hgrc.5.html"><strong>hgrc</strong>(5)</a></p>
</div>
<div class="section" id="copying">
<h1>Copying</h1>
<p>This manual page is copyright 2006 Vadim Gelfer.
Mercurial is copyright 2005-2012 Matt Mackall.
Free use of this software is granted under the terms of the GNU General
Public License version 2 or any later version.</p>
<!-- Common link and substitution definitions. -->
</div>
</div>
</body>
</html>