1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
\r
4 <article lang="en" id="git-grep(1)">
\r
6 <title>git-grep(1)</title>
\r
8 <primary>git-grep(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-grep - Print lines matching a pattern</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git grep</emphasis> [--cached]
\r
19 [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
\r
20 [-v | --invert-match] [-h|-H] [--full-name]
\r
21 [-E | --extended-regexp] [-G | --basic-regexp]
\r
22 [-F | --fixed-strings] [-n]
\r
23 [-l | --files-with-matches] [-L | --files-without-match]
\r
25 [-c | --count] [--all-match]
\r
26 [-A <post-context>] [-B <pre-context>] [-C <context>]
\r
27 [-f <file>] [-e] <pattern>
\r
28 [--and|--or|--not|(|)|-e <pattern>…] [<tree>…]
\r
29 [--] [<path>…]</literallayout>
\r
32 <simplesect id="_description">
\r
33 <title>DESCRIPTION</title>
\r
34 <simpara>Look for specified patterns in the working tree files, blobs
\r
35 registered in the index file, or given tree objects.</simpara>
\r
37 <simplesect id="_options">
\r
38 <title>OPTIONS</title>
\r
46 Instead of searching in the working tree files, check
\r
47 the blobs registered in the index file.
\r
60 Process binary files as if they were text.
\r
73 Ignore case differences between the patterns and the
\r
84 Don’t match the pattern in binary files.
\r
97 Match the pattern only at word boundary (either begin at the
\r
98 beginning of a line, or preceded by a non-word character; end at
\r
99 the end of a line or followed by a non-word character).
\r
112 Select non-matching lines.
\r
125 By default, the command shows the filename for each
\r
126 match. <literal>-h</literal> option is used to suppress this output.
\r
127 <literal>-H</literal> is there for completeness and does not do anything
\r
128 except it overrides <literal>-h</literal> given earlier on the command
\r
139 When run from a subdirectory, the command usually
\r
140 outputs paths relative to the current directory. This
\r
141 option forces paths to be output relative to the project
\r
161 Use POSIX extended/basic regexp for patterns. Default
\r
162 is to use basic regexp.
\r
175 Use fixed strings for patterns (don’t interpret pattern
\r
186 Prefix the line number to matching lines.
\r
195 --files-with-matches
\r
204 --files-without-match
\r
208 Instead of showing every matched line, show only the
\r
209 names of files that contain (or do not contain) matches.
\r
210 For better compatibility with <emphasis>git-diff</emphasis>, --name-only is a
\r
211 synonym for --files-with-matches.
\r
224 Output \0 instead of the character that normally follows a
\r
238 Instead of showing every matched line, show the number of
\r
245 -[ABC] <context>
\r
249 Show <literal>context</literal> trailing (<literal>A</literal> — after), or leading (<literal>B</literal>
\r
250  — before), or both (<literal>C</literal> — context) lines, and place a
\r
251 line containing <literal>--</literal> between contiguous groups of
\r
262 A shortcut for specifying -C<num>.
\r
272 Read patterns from <file>, one per line.
\r
282 The next parameter is the pattern. This option has to be
\r
283 used for patterns starting with - and should be used in
\r
284 scripts passing user input to grep. Multiple patterns are
\r
285 combined by <emphasis>or</emphasis>.
\r
304 Specify how multiple patterns are combined using Boolean
\r
305 expressions. <literal>--or</literal> is the default operator. <literal>--and</literal> has
\r
306 higher precedence than <literal>--or</literal>. <literal>-e</literal> has to be used for all
\r
317 When giving multiple pattern expressions combined with <literal>--or</literal>,
\r
318 this flag is specified to limit the match to files that
\r
319 have lines to match all of them.
\r
325 <literal><tree>…</literal>
\r
329 Search blobs in the trees for specified patterns.
\r
339 Signals the end of options; the rest of the parameters
\r
340 are <path> limiters.
\r
346 <simplesect id="_example">
\r
347 <title>Example</title>
\r
351 git grep -e '#define\' --and \( -e MAX_PATH -e PATH_MAX \)
\r
355 Looks for a line that has <literal>#define</literal> and either <literal>MAX_PATH</literal> or
\r
356 <literal>PATH_MAX</literal>.
\r
362 git grep --all-match -e NODE -e Unexpected
\r
366 Looks for a line that has <literal>NODE</literal> or <literal>Unexpected</literal> in
\r
367 files that have lines that match both.
\r
373 <simplesect id="_author">
\r
374 <title>Author</title>
\r
375 <simpara>Originally written by Linus Torvalds <<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>>, later
\r
376 revamped by Junio C Hamano.</simpara>
\r
378 <simplesect id="_documentation">
\r
379 <title>Documentation</title>
\r
380 <simpara>Documentation by Junio C Hamano and the git-list <<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>>.</simpara>
\r
382 <simplesect id="_git">
\r
384 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
\r