diff --git a/content/docs/command-reference/check-ignore.md b/content/docs/command-reference/check-ignore.md index f47584fb53..c22a3c0762 100644 --- a/content/docs/command-reference/check-ignore.md +++ b/content/docs/command-reference/check-ignore.md @@ -6,7 +6,7 @@ patterns found in [`.dvcignore`](/doc/user-guide/dvcignore). ## Synopsis ```usage -usage: usage: dvc check-ignore [-h] [-q | -v] [-d] [-n] +usage: usage: dvc check-ignore [-h] [-q | -v] [-d] [-a] [-n] [--stdin] targets [targets ...] positional arguments: @@ -25,10 +25,16 @@ ones that are ignored indeed are printed back. series of lines are printed in this format: `:: ` +- `-a`, `--all` - include all the patterns that match each target path in the + `--details` list. Has no effect without `--details`. + - `-n`, `--non-matching` - include the target paths which don’t match any pattern in the `--details` list. All fields in each line, except for ``, will be empty. Has no effect without `--details`. +- `--stdin` - read target paths from standard input instead of using the + `targets` arguments. Useful for interactive debugging and POSIX pipes. + - `-h`, `--help` - prints the usage/help message, and exit. - `-q`, `--quiet` - do not write anything to standard output. Exit with 0 if no @@ -83,6 +89,15 @@ $ dvc check-ignore -d file* .dvcignore:2:!file2 file2 ``` +By default, only the last pattern matched would be shown. To see all the +patterns matched, use `--all` (`-a`). + +```dvc +$ dvc check-ignore -d -a file2 +.dvcignore:1:file* file2 +.dvcignore:2:!file2 file2 +``` + With the `--non-matching` (`-n`) option, non-matching `targets` will also be included in the details list: @@ -90,3 +105,22 @@ included in the details list: $ dvc check-ignore -d -n other :: other ``` + +## Example: Check paths interactively or programmatically + +The `--stdin` option provides an interactive way to debug `.dvcignore` patterns: + +```dvc +$ dvc check-ignore --stdin +> file1 +file1 +> other +> file2 +file2 +``` + +It can also be used as a component of a POSIX pipe: + +```dvc +cat file_list | dvc check-ignore --stdin +```