hg Verified current stable Not installed? Version Control

Hg / Exclude Files Matching Pattern

Exclude Files Matching Pattern

Use hg status with exclude option to filter out specific files or patterns from the output.

$
Terminal
hg status -X <pattern>

When To Use

Omitting temporary files from the status output during code review.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
? excluded_file.txt
? temp/
? logs/

Power User Variants

Optimized versions

hg status --exclude pattern

Use long form of the exclude option.

hg status -X '*.tmp'

Exclude all temporary files with .tmp extension.

Troubleshooting

Common pitfalls

No matching files found for the pattern.

Solution: Ensure the pattern is correct and matches existing files.

Invalid option used with hg status.

Solution: Check the command syntax and ensure -X or --exclude is used correctly.

Command Breakdown

What each part is doing

hg
Base Command
The executable that performs this operation. Here it runs Hg before the shell applies any redirect operators.
-X
X| exclude
The value supplied for X| exclude.
<pattern>
pattern
The value supplied for pattern.
-X
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run `hg status -X pattern` to exclude files matching the pattern.

  2. Step 2

    Replace `pattern` with the specific file or directory name you want to exclude.

  3. Step 3

    Review the output to see the remaining changes without the excluded files.

Alternative Approaches

Comparable commands in other tools

Alternative version control tools for the same job.