1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-grep(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-grep(
1) Manual Page
409 <div class=
"sectionbody">
411 Print lines matching a pattern
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git grep
</em> [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
419 [-v | --invert-match] [-h|-H] [--full-name]
420 [-E | --extended-regexp] [-G | --basic-regexp]
421 [-F | --fixed-strings] [-n]
422 [-l | --files-with-matches] [-L | --files-without-match]
423 [(-O | --open-files-in-pager) [
<pager
>]]
425 [-c | --count] [--all-match] [-q | --quiet]
426 [--max-depth
<depth
>]
427 [--color[=
<when
>] | --no-color]
428 [-A
<post-context
>] [-B
<pre-context
>] [-C
<context
>]
429 [-f
<file
>] [-e]
<pattern
>
430 [--and|--or|--not|(|)|-e
<pattern
>…]
431 [--cached | --no-index |
<tree
>…]
432 [--] [
<pathspec
>…]
</div>
433 <div class=
"verseblock-attribution">
436 <h2 id=
"_description">DESCRIPTION
</h2>
437 <div class=
"sectionbody">
438 <div class=
"paragraph"><p>Look for specified patterns in the tracked files in the work tree, blobs
439 registered in the index file, or blobs in given tree objects.
</p></div>
441 <h2 id=
"_options">OPTIONS
</h2>
442 <div class=
"sectionbody">
443 <div class=
"dlist"><dl>
449 Instead of searching tracked files in the working tree, search
450 blobs registered in the index file.
458 Search files in the current directory, not just those tracked by git.
469 Process binary files as if they were text.
480 Ignore case differences between the patterns and the
489 Don
’t match the pattern in binary files.
493 --max-depth
<depth
>
497 For each
<pathspec
> given on command line, descend at most
<depth
>
498 levels of directories. A negative value means no limit.
509 Match the pattern only at word boundary (either begin at the
510 beginning of a line, or preceded by a non-word character; end at
511 the end of a line or followed by a non-word character).
522 Select non-matching lines.
533 By default, the command shows the filename for each
534 match.
<tt>-h
</tt> option is used to suppress this output.
535 <tt>-H
</tt> is there for completeness and does not do anything
536 except it overrides
<tt>-h
</tt> given earlier on the command
545 When run from a subdirectory, the command usually
546 outputs paths relative to the current directory. This
547 option forces paths to be output relative to the project
565 Use POSIX extended/basic regexp for patterns. Default
566 is to use basic regexp.
577 Use fixed strings for patterns (don
’t interpret pattern
586 Prefix the line number to matching lines.
602 --files-without-match
606 Instead of showing every matched line, show only the
607 names of files that contain (or do not contain) matches.
608 For better compatibility with
<em>git diff
</em>,
<tt>--name-only
</tt> is a
609 synonym for
<tt>--files-with-matches
</tt>.
616 --open-files-in-pager [
<pager
>]
620 Open the matching files in the pager (not the output of
<em>grep
</em>).
621 If the pager happens to be
"less" or
"vi", and the user
622 specified only one pattern, the first file is positioned at
623 the first match automatically.
634 Output \
0 instead of the character that normally follows a
646 Instead of showing every matched line, show the number of
651 --color[=
<when
>]
655 Show colored matches.
656 The value must be always (the default), never, or auto.
664 Turn off match highlighting, even when the configuration file
665 gives the default to color output.
666 Same as
<tt>--color=never
</tt>.
670 -[ABC]
<context
>
674 Show
<tt>context
</tt> trailing (
<tt>A
</tt> — after), or leading (
<tt>B
</tt>
675  — before), or both (
<tt>C
</tt> — context) lines, and place a
676 line containing
<tt>--
</tt> between contiguous groups of
685 A shortcut for specifying
<tt>-C
<num
></tt>.
696 Show the preceding line that contains the function name of
697 the match, unless the matching line is a function name itself.
698 The name is determined in the same way as
<em>git diff
</em> works out
699 patch hunk headers (see
<em>Defining a custom hunk-header
</em> in
700 <a href=
"gitattributes.html">gitattributes(
5)
</a>).
708 Read patterns from
<file
>, one per line.
716 The next parameter is the pattern. This option has to be
717 used for patterns starting with
<tt>-
</tt> and should be used in
718 scripts passing user input to grep. Multiple patterns are
719 combined by
<em>or
</em>.
736 Specify how multiple patterns are combined using Boolean
737 expressions.
<tt>--or
</tt> is the default operator.
<tt>--and
</tt> has
738 higher precedence than
<tt>--or
</tt>.
<tt>-e
</tt> has to be used for all
747 When giving multiple pattern expressions combined with
<tt>--or
</tt>,
748 this flag is specified to limit the match to files that
749 have lines to match all of them.
760 Do not output matched lines; instead, exit with status
0 when
761 there is a match and with non-zero status when there isn
’t.
769 Instead of searching tracked files in the working tree, search
770 blobs in the given trees.
778 Signals the end of options; the rest of the parameters
779 are
<pathspec
> limiters.
783 <pathspec
>…
787 If given, limit the search to paths matching at least one pattern.
788 Both leading paths match and glob(
7) patterns are supported.
793 <h2 id=
"_examples">Examples
</h2>
794 <div class=
"sectionbody">
795 <div class=
"dlist"><dl>
797 git grep
'time_t
' --
'*.[ch]
'
801 Looks for
<tt>time_t
</tt> in all tracked .c and .h files in the working
802 directory and its subdirectories.
806 git grep -e
'#define
' --and \( -e MAX_PATH -e PATH_MAX \)
810 Looks for a line that has
<tt>#define
</tt> and either
<tt>MAX_PATH
</tt> or
815 git grep --all-match -e NODE -e Unexpected
819 Looks for a line that has
<tt>NODE
</tt> or
<tt>Unexpected
</tt> in
820 files that have lines that match both.
825 <h2 id=
"_author">Author
</h2>
826 <div class=
"sectionbody">
827 <div class=
"paragraph"><p>Originally written by Linus Torvalds
<<a href=
"mailto:torvalds@osdl.org">torvalds@osdl.org
</a>>, later
828 revamped by Junio C Hamano.
</p></div>
830 <h2 id=
"_documentation">Documentation
</h2>
831 <div class=
"sectionbody">
832 <div class=
"paragraph"><p>Documentation by Junio C Hamano and the git-list
<<a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a>>.
</p></div>
834 <h2 id=
"_git">GIT
</h2>
835 <div class=
"sectionbody">
836 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
839 <div id=
"footer-text">
840 Last updated
2010-
09-
03 21:
29:
54 UTC