简体   繁体   English

如何在Mercurial(hg)中列出存储库中的所有文件?

[英]How to list all files in a repository in Mercurial (hg)?

Is there a command in mercurial that will list all files currently under source control? mercurial中是否有一个命令会列出当前受源代码管理的所有文件?

I can do a dir /s to list all files in my folder and subfolders, but I have no idea which have been added to my repository. 我可以用dir /s列出我的文件夹和子文件夹中的所有文件,但我不知道哪些已添加到我的存储库中。 I have a variety of excluded file types and folders and I want verify that none of them were added before I set them up in my .hgignore file. 我有各种排除的文件类型和文件夹,我想验证在我的.hgignore文件中设置它们之前没有添加它们。

hg status --all will list all the files in the tree, with a letter indicating its status: M for modified, C for clean (owned by hg), and I for ignored. hg status --all将列出树中的所有文件,并带有一个表示其状态的字母:M表示已修改,C表示清除(由hg拥有),I表示已忽略。

For just ignored files, use hg status -i . 对于刚刚忽略的文件,请使用hg status -i For just files that will be added on the next commit, use hg status -a . 对于将在下次提交时添加的文件,请使用hg status -a These show only what you need to know and don't require scanning a long file list. 这些只显示您需要知道的内容,不需要扫描长文件列表。

You might also check out the hg locate command. 您也可以查看hg locate命令。 I use it, along with the -I option when I want to limit the files to a certain directory. 当我想将文件限制到某个目录时,我使用它和-I选项。

To list all files in your repository: 列出存储库中的所有文件:

hg locate

From the repository ("root") directory: 从存储库(“root”)目录:

hg locate -I dir/sub_dir/dir_of_interest

The path passed to -I needs to change depending on the directory in which you run the command. 传递给-I的路径需要根据运行命令的目录进行更改。 If you run the command from the dir directory in the example above, you'd need to modify your argument to locate: 如果您在上面的示例中从dir目录运行命令,则需要修改您的参数以找到:

hg locate -I sub_dir/dir_of_interest

The list of output files will remain the same, showing each file's full path in the repository. 输出文件列表将保持不变,显示存储库中每个文件的完整路径。

Try hg help -v locate for more info. 尝试hg help -v locate以获取更多信息。

hg manifest将仅列出存储库中的文件,而hg status --all将列出存储库结构中的所有文件,并包括正在跟踪的标记和不标记的标记。

Listing Only Ignored Or Added Files 列出仅忽略或添加的文件

To list only the ignored files, do: hg status -i . 列出被忽略的文件,请执行: hg status -i

For just added files, do hg status -a . 对于刚添加的文件,请执行hg status -a

If you don't like typing much, you can shorten these to hg sta -i and hg sta -a . 如果你不喜欢打字,可以将它们缩短为hg sta -ihg sta -a

This two uses of status are more simple than locate and will give you the specific files states that you are concerned about, so it is significantly less error prone. status这两种用法比locate更简单,并且会为您提供您关注的特定文件状态,因此它更不容易出错。

More about hg status 更多关于hg status

To list all files in a mercurial repo do: hg status --all . 要列出mercurial repo中的所有文件,请执行以下操作: hg status --all

The files will be given a prefix before them when they are listed: 列出文件时,它们将在它们之前被赋予前缀:

  M = modified
  A = added
  R = removed
  C = clean
  ! = missing (deleted by non-hg command, but still tracked)
  ? = not tracked
  I = ignored

If you want to list only the files in a folder , you can provide a path: 如果只想列出文件夹中的文件 ,可以提供以下路径:

  • hg st --all MyFolder – all files in MyFolder hg st --all MyFolder - hg st --all MyFolder所有文件
  • hg sta -i MyFolder – just ignored files in MyFolder. hg sta -i MyFolder - 只是忽略了MyFolder中的文件。

As well as the -i for "Ignored" and -a for "Added", other flags are available to list only the files having a particular status. 除了“Ignored”的-i和“已添加”的-a ,还有其他标志可用于仅列出具有特定状态的文件。

Getting help 获得help

Read the other very useful answer here for a comprehensive explanation of the status command. 请阅读其他非常有用的答案,以获得有关status命令的全面说明。 It has down votes because the author has tried to show that you can discover all of the above by asking Mercurial about the status command like this: 由于作者试图证明你可以通过 Mercurial 询问有关status命令的信息来表明你可以发现以上所有内容,因此它的票数很低:

hg help status

You can ask Mercurial to tell you about any of it's commands like this. 您可以让Mercurial告诉您这些命令的任何内容。 And if you want a list of Mercurial's commands, then type hg help . 如果你想要一个Mercurial命令列表,那么输入hg help

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用tortoise hg“作为存储库的一部分”来忽略kiln / mercurial中的文件 - how to ignore files in kiln/mercurial using tortoise hg “that are part of the repository” Mercurial-hg命令行列出特定版本的所有文件 - Mercurial - hg command line to list all files from a specific rev 如何列出给定变更集的Mercurial存储库中存在的所有文件? - How to list all files present in a mercurial repository at a given changeset? 在Mercurial存储库的所有用户上执行汞设置 - Enforcing hg settings on all users of a mercurial repository 如何为所有丢失的文件执行Mercurial的'hg remove'? - How to do Mercurial's 'hg remove' for all missing files? 如何在Mercurial中的hg日志中获取修改后的文件列表及其修订? - How to get modified files list along with their revision in hg log in Mercurial? 水银; hg log命令显示克隆存储库内rev 0的巨大,无组织文件列表 - Mercurial; hg log command displays huge, unorganized list of files for rev 0 inside of a cloned repository 在Mercurial(hg)中,如果发出“hg push”,你如何看到将被推送的文件列表? - In Mercurial (hg), how do you see a list of files that will be pushed if an “hg push” is issued? Mercurial [HG] - 获取.hgignore排除文件的列表 - Mercurial [HG] - Get the list of .hgignore excluded files 在Mercurial(Hg)中,列出自修订版4822以来我修改的所有文件的好方法是什么? - In Mercurial (Hg), what is a good way to list all files modified by me since revision 4822?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM