Check whether any given files or directories are excluded from DVC due to the
patterns found in
usage: dvc check-ignore [-h] [-q | -v] [-d] [-a] [-n] [--stdin] targets [targets ...] positional arguments: targets File or directory paths to check
This helper command checks whether the given
targets are ignored by DVC
according to the
.dvcignore file (if any). The
ones that are ignored indeed are printed back.
--details- show the exclude patterns along with each target path. A series of lines are printed in this format:
--all- include all the patterns that match each target path in the
--detailslist. Has no effect without
--non-matching- include the target paths which don’t match any pattern in the
--detailslist. All fields in each line, except for
<target_path>, will be empty. Has no effect without
--stdin- read target paths from standard input instead of using the
targetsarguments. Useful for interactive debugging and POSIX pipes.
--help- prints the usage/help message, and exit.
--quiet- do not write anything to standard output. Exit with 0 if no problems arise, otherwise 1.
--verbose- displays detailed tracing information.
First, let's create a
.dvcignore file with some patterns in it, and some files
to check against it:
$ echo "file*\n\!file2" >> .dvcignore $ cat .dvcignore file* !file2 $ touch file1 file2 other $ ls file1 file2 other
Then, let's use
dvc check-ignore to see which of these files would be excluded
$ dvc check-ignore file1 file1 $ dvc check-ignore file1 file2 file1 file2 $ dvc check-ignore other # There's no command output, meaning `other` is not excluded. $ dvc check-ignore file* file1 file2
-d), we get a detailed report of all the matches:
$ dvc check-ignore -d file1 file2 .dvcignore:1:file* file1 .dvcignore:2:!file2 file2 $ dvc check-ignore -d file* .dvcignore:1:file* file1 .dvcignore:2:!file2 file2
By default, only the last pattern matched would be shown. To see all the
patterns matched, use
$ dvc check-ignore -d -a file2 .dvcignore:1:file* file2 .dvcignore:2:!file2 file2
-n) option, non-matching
targets will also be
included in the details list:
$ dvc check-ignore -d -n other :: other
--stdin option provides an interactive way to debug
$ dvc check-ignore --stdin > file1 file1 > other > file2 file2
It can also be used as part of a POSIX pipe:
cat file_list | dvc check-ignore --stdin