LinuxCommandLibrary

hg-status

Show modified, new, or removed Mercurial files

TLDR

Display the status of changed files

$ hg status
copy

Display only modified files
$ hg status [[-m|--modified]]
copy

Display only added files
$ hg status [[-a|--added]]
copy

Display only removed files
$ hg status [[-r|--removed]]
copy

Display only deleted (but tracked) files
$ hg status [[-d|--deleted]]
copy

Display changes in the working directory compared to a specified changeset
$ hg status --rev [revision]
copy

Display only files matching a specified glob pattern
$ hg status [[-I|--include]] [pattern]
copy

Display files, excluding those that match a specified glob pattern
$ hg status [[-X|--exclude]] [pattern]
copy

SYNOPSIS

hg status [OPTION]... [FILE]...

PARAMETERS

-0, --print0
    end filenames with NUL

-A, --all
    show all files under Mercurial control

-a, --added
    show only added files

-c, --copies
    show source of copies

-d, --deleted
    show deleted (tracked but missing) files

-I PATTERN, --include PATTERN
    include only files matching PATTERN

-i, --ignored
    show ignored files

-m, --modified
    show only modified files

-n, --no-status
    don't prepend status characters to filenames

-r, --removed
    show only removed files

-R REV, --rev REV
    compare with revision REV

-S, --subrepos
    recurse into subrepositories

-T TEMPLATE, --template TEMPLATE
    use custom template

-u, --unknown
    show only unknown (untracked) files

-X PATTERN, --exclude PATTERN
    exclude files matching PATTERN

DESCRIPTION

The hg status command provides a concise summary of changes in a Mercurial repository's working directory compared to the last commit. It lists files with status indicators such as M for modified, A for added, R for removed, ? for unknown (untracked), I for ignored, and ! for missing (deleted but tracked).

By default, it shows modified, added, removed, missing, unknown, and ignored files, but excludes clean files. Options allow filtering specific types, including all files (-A), or showing copies (-c). It supports revision comparisons (-R REV), pattern inclusion/exclusion (-I, -X), and recursion into subrepos (-S).

This command is vital for developers to inspect pending changes before committing, branching, or pushing. Output can be customized with templates (-T) or formatted for scripting (-0). When no files are specified, it scans the entire working directory; otherwise, it limits to given paths.

CAVEATS

Clean files not shown by default; use -A. Patterns are shell globs. Does not detect uncommitted changes in subrepos without -S.

STATUS LEGEND

M modified
A added
R removed
C clean
! missing
? unknown
I ignored

EXAMPLES

hg status - default summary
hg status -amru - added/modified/removed/unknown
hg status -R 1.0 - changes since rev 1.0

HISTORY

Core Mercurial command since initial release (0.1, 2005) by Matt Mackall; evolved with subrepo support in 1.3 (2009) and templating in later versions.

SEE ALSO

git(1), hg diff(1), hg summary(1)

Copied to clipboard