Differences between revisions 10 and 18 (spanning 8 versions)
Revision 10 as of 2010-10-15 05:38:57
Size: 1640
Editor: abuehl
Comment:
Revision 18 as of 2014-09-30 15:09:19
Size: 2072
Editor: mpm
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#pragma section-numbers 2

<<Include(A:style)>>
Line 3: Line 7:
The `.hgignore` file sits in the [[WorkingDirectory|working directory]], next to the `.hg` folder.
It is a file versioned as any other versioned file in the working directory,
which is used to hold the content of the ignore patterns that are used
for any command operating on the working directory.
How to ignore files.

<<TableOfContents>>

== Introduction ==

The `.hgignore` file sits in the [[WorkingDirectory|working directory]], next to the `.hg` folder. It is a file versioned as any other versioned file in the working directory, which is used to hold the content of the ignore patterns that are used for any command operating on the working directory.
Line 11: Line 18:
Line 22: Line 28:
Line 28: Line 33:
Line 34: Line 38:
Line 40: Line 43:
Line 46: Line 48:
This would match all files ending with `.o` below (within and in subdirectories at any depth of) the `target` directory.
Line 47: Line 50:
This would match all files ending with `.o` below (within and in subdirectories at any depth of) the `target` directory. == Limitations ==

There is no straightforward way to ignore all but a set of files. Attempting to use an inverted regex match will fail when combined with other patterns. This is an intentional limitation, as alternate formats were all considered far too likely to confuse users to be worth the additional flexibility.

{i} This page does not meet our wiki style guidelines. Please help improve this page by cleaning up its formatting.

.hgignore

How to ignore files.

1. Introduction

The .hgignore file sits in the working directory, next to the .hg folder. It is a file versioned as any other versioned file in the working directory, which is used to hold the content of the ignore patterns that are used for any command operating on the working directory.

Man Page: hgignore(5)

2. How it works

Each path within the repository is presented to the ignore pattern matcher, so it would be presented with something like this:

code
code/something
code/targets
code/targets/platform
target
target/executable

This is just like the output of the Unix find command. To match only target at the top level of a repository, you would use this in .hgignore (using the regex syntax):

^target$

To match anything called target elsewhere in the repository, you would need to have something like this:

/target$

The above pattern will ignore files and whole directories (by "pruning" those directories and thus ignoring their contents). If you need to ignore the contents of a directory, which is not in itself particularly useful, you would start with this pattern:

/target/

Since the above pattern would only appear in paths for files below a directory called target, it would only match those files, not the directory itself. You could then extend this pattern to match specific files, however:

/target/.*\.o$

This would match all files ending with .o below (within and in subdirectories at any depth of) the target directory.

3. Limitations

There is no straightforward way to ignore all but a set of files. Attempting to use an inverted regex match will fail when combined with other patterns. This is an intentional limitation, as alternate formats were all considered far too likely to confuse users to be worth the additional flexibility.

.hgignore (last edited 2014-09-30 15:09:19 by mpm)