Skip to content
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion content/docs/command-reference/check-ignore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -25,10 +25,16 @@ ones that are ignored indeed are printed back.
series of lines are printed in this format:
`<path/to/.dvcignore>:<line_num>:<pattern> <target_path>`

- `-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
`<target_path>`, 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
Expand Down Expand Up @@ -83,10 +89,38 @@ $ 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:

```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
Comment thread
jorgeorpinel marked this conversation as resolved.
```

It can also be used as a component of a POSIX pipe:

```dvc
cat file_list | dvc check-ignore --stdin
```