diff --git a/content/docs/command-reference/check-ignore.md b/content/docs/command-reference/check-ignore.md index 4a99f6d591..2d154e6931 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: @@ -37,6 +37,12 @@ ones that are ignored indeed are printed back. - `-v`, `--verbose` - displays detailed tracing information. +- `--stdin` - read paths from standard input instead of providing `targets`. + Useful for interactive debugging and POSIX pipes. + +- `-a`, `--all` - include all the patterns that match each target path in the + `--details` list. Has no effect without `--details`. + ## Examples First, let's create a `.dvcignore` file with some patterns in it, and some files @@ -81,10 +87,39 @@ $ dvc check-ignore -d file* .dvcignore:2:!file2 file2 ``` -With the `--non-matching` option, non-matching `targets` will also be included -in the list. All fields in each line, except for ``, will be empty. +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 list. All fields in each line, except for ``, will +be empty. ```dvc $ 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 +```