hg-commit
Record changes to the repository
TLDR
Commit staged files to the repository
Commit a specific file or directory
Commit with a specific message
Commit all files matching a specified pattern
Commit all files, excluding those that match a specified pattern
Commit using the interactive mode
SYNOPSIS
hg commit [OPTION]... [FILE]...
PARAMETERS
-A, --addremove
Add new files, remove deleted ones automatically
-m TEXT, --message TEXT
Commit message as TEXT
-l FILE, --logfile FILE
Read message from FILE
-r REV, --rev REV
Commit to specific REV (updates first)
-u USER, --user USER
Record USER as committer
-d DATE, --date DATE
Set commit DATE
--amend
Amend previous commit
--close-branch
Mark branch head closed
-I, --include PATTERN
Include files matching PATTERN
-X, --exclude PATTERN
Exclude files matching PATTERN
-S, --subrepos
Commit in subrepositories
--no-verify
Skip pre-commit hooks
DESCRIPTION
The hg commit command records changes to files in a Mercurial repository, creating a new changeset.
It stages modifications, additions, or deletions specified by files or defaults to all modified files if none provided. A commit message is required, either via -m or an editor.
By default, it commits to the current working directory's parent revision on the active branch. Use options to include/exclude files, amend previous commits, or handle subrepositories.
Commits are local until pushed. Ensures atomic changesets for collaboration. Interactive mode unavailable; use hg record for patch-by-patch commits.
Ideal for versioning code, configs, or data. Integrates with hooks for validation.
CAVEATS
Must run inside repository; no files specified commits all changes. Empty message prompts editor. Amending rewrites history—avoid shared repos.
EXAMPLES
hg commit -m "Fix bug"
Commit all changes with message.
hg commit -A file.txt
Commit file.txt, auto-add/remove.
hg commit --amend -m "Better message"
Amend last commit.
EXIT STATUS
0: success.
1: aborted (editor, hooks).
>1: errors.
HISTORY
Mercurial (hg) created 2005 by Matt Mackall for scalable DVCS. commit subcommand core since v0.9b, inspired by CVS/SVN but distributed. Evolved with amend (v1.9, 2010), subrepo support.
SEE ALSO
git-commit(1), hg-status(1), hg-log(1), hg-record(1), hg-push(1)


