如何列出 Mercurial (hg) 中存储库中的所有文件?
Mercurial 中是否有一个命令可以列出当前受源代码控制的所有文件?
我可以执行 dir /s
来列出我的文件夹和子文件夹中的所有文件,但我不知道哪些文件已添加到我的存储库中。我有各种排除的文件类型和文件夹,我想验证在将它们设置到 .hgignore 文件中之前是否未添加任何文件类型和文件夹。
Is there a command in mercurial that will list all files currently under source control?
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. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
hg status --all
将列出树中的所有文件,并用字母指示其状态:M 表示已修改,C 表示干净(由 hg 拥有),I 表示忽略。对于忽略文件,请使用
hg status -i
。对于仅在下次提交时添加的文件,请使用hg status -a
。这些仅显示您需要了解的内容,不需要扫描长文件列表。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.For just ignored files, use
hg status -i
. For just files that will be added on the next commit, usehg status -a
. These show only what you need to know and don't require scanning a long file list.您还可以查看
hglocate
命令。当我想将文件限制到某个目录时,我会使用它以及-I
选项。要列出存储库中的所有文件:
从存储库(“根”)目录:
传递到
-I
的路径需要根据运行命令的目录进行更改。如果您从上例中的 dir 目录运行命令,则需要修改参数以定位:输出文件列表将保持不变,显示每个文件在存储库中的完整路径。
尝试
hg help -vlocate
了解更多信息。You might also check out the
hg locate
command. I use it, along with the-I
option when I want to limit the files to a certain directory.To list all files in your repository:
From the repository ("root") directory:
The path passed to
-I
needs to change depending on the directory in which you run the command. If you run the command from thedir
directory in the example above, you'd need to modify your argument to locate: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 manifest
将仅列出存储库中的文件,而hg status --all
将列出存储库结构中的所有文件,并包含正在跟踪的标记和哪些不是。hg manifest
will list only the files in the repository, whilehg status --all
will list all the files in the repository's structure and include a marker for which are being tracked and which aren't.仅列出被忽略或添加的文件
要仅列出被忽略的文件,请执行:
hg status -i
。对于刚刚添加的文件,请执行
hg status -a
。如果您不太喜欢打字,可以将它们缩短为
hg sta -i
和hg sta -a
。status
的这两种用法比locate
更简单,并且会为您提供您关心的特定文件状态,因此显着减少出错的可能性。有关
hg status
的更多信息要列出 Mercurial 存储库中的所有文件,请执行以下操作:
hg status --all
。列出文件时,系统会在文件前面添加前缀:
如果您想仅列出文件夹中的文件,您可以提供路径:
hg st --all MyFolder – MyFolder 中的所有文件
hg sta -i MyFolder
– 仅忽略 MyFolder 中的文件。除了表示“已忽略”的
-i
和表示“已添加”的-a
之外,还可以使用其他标志仅列出具有特定状态的文件。获取
帮助
阅读此处的其他非常有用的答案以获取
状态的全面解释
命令。它被否决是因为作者试图表明您可以通过询问 Mercurial 关于status
命令来发现上述所有内容,如下所示:您可以要求 Mercurial 告诉您关于它的任何命令都是这样的。如果您想要 Mercurial 命令的列表,请输入
hg help
。Listing Only Ignored Or Added Files
To list only the ignored files, do:
hg status -i
.For just added files, do
hg status -a
.If you don't like typing much, you can shorten these to
hg sta -i
andhg sta -a
.This two uses of
status
are more simple thanlocate
and will give you the specific files states that you are concerned about, so it is significantly less error prone.More about
hg status
To list all files in a mercurial repo do:
hg status --all
.The files will be given a prefix before them when they are listed:
If you want to list only the files in a folder, you can provide a path:
hg st --all MyFolder
– all files in MyFolderhg sta -i MyFolder
– just ignored files in 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.Getting
help
Read the other very useful answer here for a comprehensive explanation of the
status
command. It has down votes because the author has tried to show that you can discover all of the above by asking Mercurial about thestatus
command like this:You can ask Mercurial to tell you about any of it's commands like this. And if you want a list of Mercurial's commands, then type
hg help
.