How to list all files in a repository in Mercurial (hg)?
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, use 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. 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:
hg locate
From the repository ("root") directory:
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. If you run the command from the dir
directory in the example above, you'd need to modify your argument to locate:
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 manifest
will list only the files in the repository, while hg 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.
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
and hg 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.
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:
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 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 the status
command like this:
hg help status
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
.