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 [-A <post-context>] [-B <pre-context>] [-C <context>]
21 [-f <file>] [-e] <pattern>
22 [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
27 Look for specified patterns in the working tree files, blobs
28 registered in the index file, or given tree objects.
34 Instead of searching in the working tree files, check
35 the blobs registered in the index file.
39 Process binary files as if they were text.
43 Ignore case differences between the patterns and the
47 Don't match the pattern in binary files.
51 Match the pattern only at word boundary (either begin at the
52 beginning of a line, or preceded by a non-word character; end at
53 the end of a line or followed by a non-word character).
57 Select non-matching lines.
61 By default, the command shows the filename for each
62 match. `-h` option is used to suppress this output.
63 `-H` is there for completeness and does not do anything
64 except it overrides `-h` given earlier on the command
68 When run from a subdirectory, the command usually
69 outputs paths relative to the current directory. This
70 option forces paths to be output relative to the project
77 Use POSIX extended/basic regexp for patterns. Default
78 is to use basic regexp.
82 Use fixed strings for patterns (don't interpret pattern
86 Prefix the line number to matching lines.
89 --files-with-matches::
92 --files-without-match::
93 Instead of showing every matched line, show only the
94 names of files that contain (or do not contain) matches.
95 For better compatibility with 'git-diff', --name-only is a
96 synonym for --files-with-matches.
100 Output \0 instead of the character that normally follows a
105 Instead of showing every matched line, show the number of
109 Show `context` trailing (`A` -- after), or leading (`B`
110 -- before), or both (`C` -- context) lines, and place a
111 line containing `--` between contiguous groups of
115 A shortcut for specifying -C<num>.
118 Read patterns from <file>, one per line.
121 The next parameter is the pattern. This option has to be
122 used for patterns starting with - and should be used in
123 scripts passing user input to grep. Multiple patterns are
130 Specify how multiple patterns are combined using Boolean
131 expressions. `--or` is the default operator. `--and` has
132 higher precedence than `--or`. `-e` has to be used for all
136 When giving multiple pattern expressions combined with `--or`,
137 this flag is specified to limit the match to files that
138 have lines to match all of them.
141 Search blobs in the trees for specified patterns.
144 Signals the end of options; the rest of the parameters
151 git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
152 Looks for a line that has `#define` and either `MAX_PATH` or
155 git grep --all-match -e NODE -e Unexpected::
156 Looks for a line that has `NODE` or `Unexpected` in
157 files that have lines that match both.
161 Originally written by Linus Torvalds <torvalds@osdl.org>, later
162 revamped by Junio C Hamano.
167 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
171 Part of the linkgit:git[1] suite