Documentation / git-check-ignore.txton commit Sync with 2.4.9 (3d3caf0)
   1git-check-ignore(1)
   2===================
   3
   4NAME
   5----
   6git-check-ignore - Debug gitignore / exclude files
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git check-ignore' [options] pathname...
  13'git check-ignore' [options] --stdin < <list-of-paths>
  14
  15DESCRIPTION
  16-----------
  17
  18For each pathname given via the command-line or from a file via
  19`--stdin`, show the pattern from .gitignore (or other input files to
  20the exclude mechanism) that decides if the pathname is excluded or
  21included.  Later patterns within a file take precedence over earlier
  22ones.
  23
  24By default, tracked files are not shown at all since they are not
  25subject to exclude rules; but see `--no-index'.
  26
  27OPTIONS
  28-------
  29-q, --quiet::
  30        Don't output anything, just set exit status.  This is only
  31        valid with a single pathname.
  32
  33-v, --verbose::
  34        Also output details about the matching pattern (if any)
  35        for each given pathname.
  36
  37--stdin::
  38        Read file names from stdin instead of from the command-line.
  39
  40-z::
  41        The output format is modified to be machine-parseable (see
  42        below).  If `--stdin` is also given, input paths are separated
  43        with a NUL character instead of a linefeed character.
  44
  45-n, --non-matching::
  46        Show given paths which don't match any pattern.  This only
  47        makes sense when `--verbose` is enabled, otherwise it would
  48        not be possible to distinguish between paths which match a
  49        pattern and those which don't.
  50
  51--no-index::
  52        Don't look in the index when undertaking the checks. This can
  53        be used to debug why a path became tracked by e.g. `git add .`
  54        and was not ignored by the rules as expected by the user or when
  55        developing patterns including negation to match a path previously
  56        added with `git add -f`.
  57
  58OUTPUT
  59------
  60
  61By default, any of the given pathnames which match an ignore pattern
  62will be output, one per line.  If no pattern matches a given path,
  63nothing will be output for that path; this means that path will not be
  64ignored.
  65
  66If `--verbose` is specified, the output is a series of lines of the form:
  67
  68<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
  69
  70<pathname> is the path of a file being queried, <pattern> is the
  71matching pattern, <source> is the pattern's source file, and <linenum>
  72is the line number of the pattern within that source.  If the pattern
  73contained a `!` prefix or `/` suffix, it will be preserved in the
  74output.  <source> will be an absolute path when referring to the file
  75configured by `core.excludesFile`, or relative to the repository root
  76when referring to `.git/info/exclude` or a per-directory exclude file.
  77
  78If `-z` is specified, the pathnames in the output are delimited by the
  79null character; if `--verbose` is also specified then null characters
  80are also used instead of colons and hard tabs:
  81
  82<source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL>
  83
  84If `-n` or `--non-matching` are specified, non-matching pathnames will
  85also be output, in which case all fields in each output record except
  86for <pathname> will be empty.  This can be useful when running
  87non-interactively, so that files can be incrementally streamed to
  88STDIN of a long-running check-ignore process, and for each of these
  89files, STDOUT will indicate whether that file matched a pattern or
  90not.  (Without this option, it would be impossible to tell whether the
  91absence of output for a given file meant that it didn't match any
  92pattern, or that the output hadn't been generated yet.)
  93
  94Buffering happens as documented under the `GIT_FLUSH` option in
  95linkgit:git[1].  The caller is responsible for avoiding deadlocks
  96caused by overfilling an input buffer or reading from an empty output
  97buffer.
  98
  99EXIT STATUS
 100-----------
 101
 1020::
 103        One or more of the provided paths is ignored.
 104
 1051::
 106        None of the provided paths are ignored.
 107
 108128::
 109        A fatal error was encountered.
 110
 111SEE ALSO
 112--------
 113linkgit:gitignore[5]
 114linkgit:gitconfig[5]
 115linkgit:git-ls-files[1]
 116
 117GIT
 118---
 119Part of the linkgit:git[1] suite