Documentation / git-grep.txton commit GIT v1.5.2-rc1 (4c16112)
   1git-grep(1)
   2===========
   3
   4NAME
   5----
   6git-grep - Print lines matching a pattern
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git-grep' [--cached]
  13           [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
  14           [-v | --invert-match] [-h|-H] [--full-name]
  15           [-E | --extended-regexp] [-G | --basic-regexp]
  16           [-F | --fixed-strings] [-n]
  17           [-l | --files-with-matches] [-L | --files-without-match]
  18           [-c | --count] [--all-match]
  19           [-A <post-context>] [-B <pre-context>] [-C <context>]
  20           [-f <file>] [-e] <pattern>
  21           [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
  22           [--] [<path>...]
  23
  24DESCRIPTION
  25-----------
  26Look for specified patterns in the working tree files, blobs
  27registered in the index file, or given tree objects.
  28
  29
  30OPTIONS
  31-------
  32--cached::
  33        Instead of searching in the working tree files, check
  34        the blobs registered in the index file.
  35
  36-a | --text::
  37        Process binary files as if they were text.
  38
  39-i | --ignore-case::
  40        Ignore case differences between the patterns and the
  41        files.
  42
  43-I::
  44        Don't match the pattern in binary files.
  45
  46-w | --word-regexp::
  47        Match the pattern only at word boundary (either begin at the
  48        beginning of a line, or preceded by a non-word character; end at
  49        the end of a line or followed by a non-word character).
  50
  51-v | --invert-match::
  52        Select non-matching lines.
  53
  54-h | -H::
  55        By default, the command shows the filename for each
  56        match.  `-h` option is used to suppress this output.
  57        `-H` is there for completeness and does not do anything
  58        except it overrides `-h` given earlier on the command
  59        line.
  60
  61--full-name::
  62        When run from a subdirectory, the command usually
  63        outputs paths relative to the current directory.  This
  64        option forces paths to be output relative to the project
  65        top directory.
  66
  67-E | --extended-regexp | -G | --basic-regexp::
  68        Use POSIX extended/basic regexp for patterns.  Default
  69        is to use basic regexp.
  70
  71-F | --fixed-strings::
  72        Use fixed strings for patterns (don't interpret pattern
  73        as a regex).
  74
  75-n::
  76        Prefix the line number to matching lines.
  77
  78-l | --files-with-matches | -L | --files-without-match::
  79        Instead of showing every matched line, show only the
  80        names of files that contain (or do not contain) matches.
  81
  82-c | --count::
  83        Instead of showing every matched line, show the number of
  84        lines that match.
  85
  86-[ABC] <context>::
  87        Show `context` trailing (`A` -- after), or leading (`B`
  88        -- before), or both (`C` -- context) lines, and place a
  89        line containing `--` between contiguous groups of
  90        matches.
  91
  92-<num>::
  93        A shortcut for specifying -C<num>.
  94
  95-f <file>::
  96        Read patterns from <file>, one per line.
  97
  98-e::
  99        The next parameter is the pattern. This option has to be
 100        used for patterns starting with - and should be used in
 101        scripts passing user input to grep.  Multiple patterns are
 102        combined by 'or'.
 103
 104--and | --or | --not | ( | )::
 105        Specify how multiple patterns are combined using Boolean
 106        expressions.  `--or` is the default operator.  `--and` has
 107        higher precedence than `--or`.  `-e` has to be used for all
 108        patterns.
 109
 110--all-match::
 111        When giving multiple pattern expressions combined with `--or`,
 112        this flag is specified to limit the match to files that
 113        have lines to match all of them.
 114
 115`<tree>...`::
 116        Search blobs in the trees for specified patterns.
 117
 118\--::
 119        Signals the end of options; the rest of the parameters
 120        are <path> limiters.
 121
 122
 123Example
 124-------
 125
 126git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
 127        Looks for a line that has `#define` and either `MAX_PATH` or
 128        `PATH_MAX`.
 129
 130git grep --all-match -e NODE -e Unexpected::
 131        Looks for a line that has `NODE` or `Unexpected` in
 132        files that have lines that match both.
 133
 134Author
 135------
 136Originally written by Linus Torvalds <torvalds@osdl.org>, later
 137revamped by Junio C Hamano.
 138
 139
 140Documentation
 141--------------
 142Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 143
 144GIT
 145---
 146Part of the gitlink:git[7] suite
 147