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=
"_configuration">CONFIGURATION
</h2>
442 <div class=
"sectionbody">
443 <div class=
"dlist"><dl>
449 If set to true, enable
<em>-n
</em> option by default.
457 If set to true, enable
<em>--extended-regexp
</em> option by default.
462 <h2 id=
"_options">OPTIONS
</h2>
463 <div class=
"sectionbody">
464 <div class=
"dlist"><dl>
470 Instead of searching tracked files in the working tree, search
471 blobs registered in the index file.
479 Search files in the current directory, not just those tracked by git.
490 Process binary files as if they were text.
501 Ignore case differences between the patterns and the
510 Don
’t match the pattern in binary files.
514 --max-depth
<depth
>
518 For each
<pathspec
> given on command line, descend at most
<depth
>
519 levels of directories. A negative value means no limit.
530 Match the pattern only at word boundary (either begin at the
531 beginning of a line, or preceded by a non-word character; end at
532 the end of a line or followed by a non-word character).
543 Select non-matching lines.
554 By default, the command shows the filename for each
555 match.
<tt>-h
</tt> option is used to suppress this output.
556 <tt>-H
</tt> is there for completeness and does not do anything
557 except it overrides
<tt>-h
</tt> given earlier on the command
566 When run from a subdirectory, the command usually
567 outputs paths relative to the current directory. This
568 option forces paths to be output relative to the project
586 Use POSIX extended/basic regexp for patterns. Default
587 is to use basic regexp.
598 Use fixed strings for patterns (don
’t interpret pattern
610 Prefix the line number to matching lines.
626 --files-without-match
630 Instead of showing every matched line, show only the
631 names of files that contain (or do not contain) matches.
632 For better compatibility with
<em>git diff
</em>,
<tt>--name-only
</tt> is a
633 synonym for
<tt>--files-with-matches
</tt>.
640 --open-files-in-pager [
<pager
>]
644 Open the matching files in the pager (not the output of
<em>grep
</em>).
645 If the pager happens to be
"less" or
"vi", and the user
646 specified only one pattern, the first file is positioned at
647 the first match automatically.
658 Output \
0 instead of the character that normally follows a
670 Instead of showing every matched line, show the number of
675 --color[=
<when
>]
679 Show colored matches.
680 The value must be always (the default), never, or auto.
688 Turn off match highlighting, even when the configuration file
689 gives the default to color output.
690 Same as
<tt>--color=never
</tt>.
694 -[ABC]
<context
>
698 Show
<tt>context
</tt> trailing (
<tt>A
</tt> — after), or leading (
<tt>B
</tt>
699  — before), or both (
<tt>C
</tt> — context) lines, and place a
700 line containing
<tt>--
</tt> between contiguous groups of
709 A shortcut for specifying
<tt>-C
<num
></tt>.
720 Show the preceding line that contains the function name of
721 the match, unless the matching line is a function name itself.
722 The name is determined in the same way as
<em>git diff
</em> works out
723 patch hunk headers (see
<em>Defining a custom hunk-header
</em> in
724 <a href=
"gitattributes.html">gitattributes(
5)
</a>).
732 Read patterns from
<file
>, one per line.
740 The next parameter is the pattern. This option has to be
741 used for patterns starting with
<tt>-
</tt> and should be used in
742 scripts passing user input to grep. Multiple patterns are
743 combined by
<em>or
</em>.
760 Specify how multiple patterns are combined using Boolean
761 expressions.
<tt>--or
</tt> is the default operator.
<tt>--and
</tt> has
762 higher precedence than
<tt>--or
</tt>.
<tt>-e
</tt> has to be used for all
771 When giving multiple pattern expressions combined with
<tt>--or
</tt>,
772 this flag is specified to limit the match to files that
773 have lines to match all of them.
784 Do not output matched lines; instead, exit with status
0 when
785 there is a match and with non-zero status when there isn
’t.
793 Instead of searching tracked files in the working tree, search
794 blobs in the given trees.
802 Signals the end of options; the rest of the parameters
803 are
<pathspec
> limiters.
807 <pathspec
>…
811 If given, limit the search to paths matching at least one pattern.
812 Both leading paths match and glob(
7) patterns are supported.
817 <h2 id=
"_examples">Examples
</h2>
818 <div class=
"sectionbody">
819 <div class=
"dlist"><dl>
821 git grep
'time_t
' --
'*.[ch]
'
825 Looks for
<tt>time_t
</tt> in all tracked .c and .h files in the working
826 directory and its subdirectories.
830 git grep -e
'#define
' --and \( -e MAX_PATH -e PATH_MAX \)
834 Looks for a line that has
<tt>#define
</tt> and either
<tt>MAX_PATH
</tt> or
839 git grep --all-match -e NODE -e Unexpected
843 Looks for a line that has
<tt>NODE
</tt> or
<tt>Unexpected
</tt> in
844 files that have lines that match both.
849 <h2 id=
"_git">GIT
</h2>
850 <div class=
"sectionbody">
851 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
854 <div id=
"footer-text">
855 Last updated
2011-
04-
02 04:
31:
58 UTC