← 返回命令列表

Linux command

hg-add 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Add a specific file

hg add [file]

Add all new files

hg add

Add files by pattern

hg add '*.py'

Add files in directory

hg add [path/to/directory]

Dry run to preview

hg add -n [file]

说明

hg add schedules files to be added to the repository on the next commit. Without arguments, it adds all new files in the working directory. Use a .hgignore file to exclude files from version control. Added files appear with 'A' status in hg status until committed.

参数

-n, --dry-run
Show what would be added without modifying state.
-I, --include _PATTERN_
Add only files matching the pattern (repeatable).
-X, --exclude _PATTERN_
Skip files matching the pattern (repeatable).
-S, --subrepos
Recurse into subrepositories.

FAQ

What is the hg-add command used for?

hg add schedules files to be added to the repository on the next commit. Without arguments, it adds all new files in the working directory. Use a .hgignore file to exclude files from version control. Added files appear with 'A' status in hg status until committed.

How do I run a basic hg-add example?

Run `hg add [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n, --dry-run do in hg-add?

Show what would be added without modifying state.