6 git-grep - Print lines matching a pattern
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]
19 [-c | --count] [--all-match]
20 [--color | --no-color]
21 [-A <post-context>] [-B <pre-context>] [-C <context>]
22 [-f <file>] [-e] <pattern>
23 [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
28 Look for specified patterns in the working tree files, blobs
29 registered in the index file, or given tree objects.
35 Instead of searching in the working tree files, check
36 the blobs registered in the index file.
40 Process binary files as if they were text.
44 Ignore case differences between the patterns and the
48 Don't match the pattern in binary files.
52 Match the pattern only at word boundary (either begin at the
53 beginning of a line, or preceded by a non-word character; end at
54 the end of a line or followed by a non-word character).
58 Select non-matching lines.
62 By default, the command shows the filename for each
63 match. `-h` option is used to suppress this output.
64 `-H` is there for completeness and does not do anything
65 except it overrides `-h` given earlier on the command
69 When run from a subdirectory, the command usually
70 outputs paths relative to the current directory. This
71 option forces paths to be output relative to the project
78 Use POSIX extended/basic regexp for patterns. Default
79 is to use basic regexp.
83 Use fixed strings for patterns (don't interpret pattern
87 Prefix the line number to matching lines.
90 --files-with-matches::
93 --files-without-match::
94 Instead of showing every matched line, show only the
95 names of files that contain (or do not contain) matches.
96 For better compatibility with 'git-diff', --name-only is a
97 synonym for --files-with-matches.
101 Output \0 instead of the character that normally follows a
106 Instead of showing every matched line, show the number of
110 Show colored matches.
113 Turn off match highlighting, even when the configuration file
114 gives the default to color output.
117 Show `context` trailing (`A` -- after), or leading (`B`
118 -- before), or both (`C` -- context) lines, and place a
119 line containing `--` between contiguous groups of
123 A shortcut for specifying -C<num>.
126 Read patterns from <file>, one per line.
129 The next parameter is the pattern. This option has to be
130 used for patterns starting with - and should be used in
131 scripts passing user input to grep. Multiple patterns are
138 Specify how multiple patterns are combined using Boolean
139 expressions. `--or` is the default operator. `--and` has
140 higher precedence than `--or`. `-e` has to be used for all
144 When giving multiple pattern expressions combined with `--or`,
145 this flag is specified to limit the match to files that
146 have lines to match all of them.
149 Search blobs in the trees for specified patterns.
152 Signals the end of options; the rest of the parameters
159 git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
160 Looks for a line that has `#define` and either `MAX_PATH` or
163 git grep --all-match -e NODE -e Unexpected::
164 Looks for a line that has `NODE` or `Unexpected` in
165 files that have lines that match both.
169 Originally written by Linus Torvalds <torvalds@osdl.org>, later
170 revamped by Junio C Hamano.
175 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
179 Part of the linkgit:git[1] suite