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