mercurial中是否有一个命令会列出当前受源代码管理的所有文件?
我可以执行dir /s
列出我的文件夹和子文件夹中的所有文件,但我不知道哪些文件已添加到我的存储库中。我有各种排除的文件类型和文件夹,我想验证在我的.hgignore文件中设置它们之前没有添加它们。
答案 0 :(得分:70)
hg status --all
将列出树中的所有文件,并带有一个表示其状态的字母:M表示修改,C表示清除(由hg拥有),I表示忽略。
对于忽略的文件,请使用hg status -i
。对于下次提交时添加的文件,请使用hg status -a
。这些仅显示您需要知道的内容,不需要扫描长文件列表。
答案 1 :(得分:61)
您也可以查看hg locate
命令。当我想将文件限制在某个目录时,我会使用它和-I
选项。
列出存储库中的所有文件:
hg locate
从存储库(“root”)目录:
hg locate -I dir/sub_dir/dir_of_interest
传递给-I
的路径需要根据运行命令的目录进行更改。如果您从上面示例中的dir
目录运行命令,则需要修改您的参数以找到:
hg locate -I sub_dir/dir_of_interest
输出文件列表将保持不变,显示存储库中每个文件的完整路径。
请尝试hg help -v locate
了解详情。
答案 2 :(得分:22)
hg manifest
将仅列出存储库中的文件,而hg status --all
将列出存储库结构中的所有文件,并包含正在跟踪的标记,哪些不是。
答案 3 :(得分:3)
要列出 忽略文件,请执行:hg status -i
。
仅针对添加的文件,执行hg status -a
。
如果您不喜欢打字,可以将这些内容缩短为hg sta -i
和hg sta -a
。
status
的这两种用法比locate
更简单,并且会为您提供您关注的特定文件状态,因此它更不容易出错。
hg status
列出mercurial repo中的所有文件:hg status --all
。
列出文件时,前面会有一个前缀:
M = modified
A = added
R = removed
C = clean
! = missing (deleted by non-hg command, but still tracked)
? = not tracked
I = ignored
如果您想列出仅列出文件夹中的文件,您可以提供路径:
hg st --all MyFolder
- MyFolder中的所有文件hg sta -i MyFolder
- 只是忽略了MyFolder中的文件。除了-i
为“已忽略”和-a
为“已添加”,其他标志可用于仅列出具有特定状态的文件。
help
阅读the other very useful answer here以获取status
命令的全面说明。由于作者试图证明你可以通过询问 Mercurial关于status
这样的命令来发现以上所有内容,所以它有很少的选票:
hg help status
你可以要求Mercurial告诉你这些命令。如果您需要Mercurial命令列表,请键入hg help
。
答案 4 :(得分:-3)
C:\>hg help -v status hg status [OPTION]... [FILE]... aliases: st show changed files in the working directory Show status of files in the repository. If names are given, only files that match are shown. Files that are clean or ignored or the source of a copy/move operation, are not listed unless -c/--clean, -i/--ignored, -C/--copies or -A/--all are given. Unless options described with "show only ..." are given, the options -mardu are used. Option -q/--quiet hides untracked (unknown and ignored) files unless explicitly requested with -u/--unknown or -i/--ignored. NOTE: status may appear to disagree with diff if permissions have changed or a merge has occurred. The standard diff format does not report permission changes and diff only reports changes relative to one merge parent. If one revision is given, it is used as the base revision. If two revisions are given, the differences between them are shown. The --change option can also be used as a shortcut to list the changed files of a revision from its first parent. The codes used to show the status of files are: M = modified A = added R = removed C = clean ! = missing (deleted by non-hg command, but still tracked) ? = not tracked I = ignored = origin of the previous file listed as A (added) options: -A --all show status of all files -m --modified show only modified files -a --added show only added files -r --removed show only removed files -d --deleted show only deleted (but tracked) files -c --clean show only files without changes -u --unknown show only unknown (not tracked) files -i --ignored show only ignored files -n --no-status hide status prefix -C --copies show source of copied files -0 --print0 end filenames with NUL, for use with xargs --rev show difference from revision --change list the changed files of a revision -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns global options: -R --repository repository root directory or name of overlay bundle file --cwd change working directory -y --noninteractive do not prompt, assume 'yes' for any required answers -q --quiet suppress output -v --verbose enable additional output --config set/override config option (use 'section.name=value') --debug enable debugging output --debugger start debugger --encoding set the charset encoding (default: cp1252) --encodingmode set the charset encoding mode (default: strict) --traceback always print a traceback on exception --time time how long the command takes --profile print command execution profile --version output version information and exit -h --help display help and exit