hg Verified current stable Not installed? Version Control

Hg / Add All Unstaged Files Matching Pattern

Add All Unstaged Files Matching Pattern

Use hg add to stage all unstaged files matching a specific pattern for your commit.

$
Terminal
hg add -I <pattern>

When To Use

Selectively stage files for a commit based on specific patterns or types.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
hg add -I <pattern>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
adding file1.txt
adding file2.txt
adding file3.log

Power User Variants

Optimized versions

hg add --include '*.txt'

Stage all unstaged .txt files.

hg add -I '*.log'

Stage all unstaged .log files.

Unix Pipeline

Shell combinations

hg add -I '*.py'

Stage all unstaged Python files.

hg add -I 'src/*'

Stage all unstaged files in the src directory.

Troubleshooting

Common pitfalls

No files matching the pattern found.

Solution: Check the pattern syntax and ensure files exist.

Command not found: hg.

Solution: Install Mercurial or check your PATH.

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.
-I
I| include
The value supplied for I| include.
<pattern>
pattern
The value supplied for pattern.
-I
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Open your terminal and navigate to your repository.

  2. Step 2

    Run the command: hg add -I 'pattern' to stage matching files.

  3. Step 3

    Verify staged files with hg status.

Alternative Approaches

Comparable commands in other tools

Alternative version control tools for the same job.