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]
422 [-F | --fixed-strings] [-n | --line-number]
423 [-l | --files-with-matches] [-L | --files-without-match]
424 [(-O | --open-files-in-pager) [
<pager
>]]
426 [-c | --count] [--all-match] [-q | --quiet]
427 [--max-depth
<depth
>]
428 [--color[=
<when
>] | --no-color]
429 [-A
<post-context
>] [-B
<pre-context
>] [-C
<context
>]
430 [-f
<file
>] [-e]
<pattern
>
431 [--and|--or|--not|(|)|-e
<pattern
>…]
432 [--cached | --no-index |
<tree
>…]
433 [--] [
<pathspec
>…]
</div>
434 <div class=
"verseblock-attribution">
437 <h2 id=
"_description">DESCRIPTION
</h2>
438 <div class=
"sectionbody">
439 <div class=
"paragraph"><p>Look for specified patterns in the tracked files in the work tree, blobs
440 registered in the index file, or blobs in given tree objects.
</p></div>
442 <h2 id=
"_configuration">CONFIGURATION
</h2>
443 <div class=
"sectionbody">
444 <div class=
"dlist"><dl>
450 If set to true, enable
<em>-n
</em> option by default.
458 If set to true, enable
<em>--extended-regexp
</em> option by default.
463 <h2 id=
"_options">OPTIONS
</h2>
464 <div class=
"sectionbody">
465 <div class=
"dlist"><dl>
471 Instead of searching tracked files in the working tree, search
472 blobs registered in the index file.
480 Search files in the current directory, not just those tracked by git.
491 Process binary files as if they were text.
502 Ignore case differences between the patterns and the
511 Don
’t match the pattern in binary files.
515 --max-depth
<depth
>
519 For each
<pathspec
> given on command line, descend at most
<depth
>
520 levels of directories. A negative value means no limit.
531 Match the pattern only at word boundary (either begin at the
532 beginning of a line, or preceded by a non-word character; end at
533 the end of a line or followed by a non-word character).
544 Select non-matching lines.
555 By default, the command shows the filename for each
556 match.
<tt>-h
</tt> option is used to suppress this output.
557 <tt>-H
</tt> is there for completeness and does not do anything
558 except it overrides
<tt>-h
</tt> given earlier on the command
567 When run from a subdirectory, the command usually
568 outputs paths relative to the current directory. This
569 option forces paths to be output relative to the project
587 Use POSIX extended/basic regexp for patterns. Default
588 is to use basic regexp.
599 Use Perl-compatible regexp for patterns. Requires libpcre to be
611 Use fixed strings for patterns (don
’t interpret pattern
623 Prefix the line number to matching lines.
639 --files-without-match
643 Instead of showing every matched line, show only the
644 names of files that contain (or do not contain) matches.
645 For better compatibility with
<em>git diff
</em>,
<tt>--name-only
</tt> is a
646 synonym for
<tt>--files-with-matches
</tt>.
653 --open-files-in-pager [
<pager
>]
657 Open the matching files in the pager (not the output of
<em>grep
</em>).
658 If the pager happens to be
"less" or
"vi", and the user
659 specified only one pattern, the first file is positioned at
660 the first match automatically.
671 Output \
0 instead of the character that normally follows a
683 Instead of showing every matched line, show the number of
688 --color[=
<when
>]
692 Show colored matches.
693 The value must be always (the default), never, or auto.
701 Turn off match highlighting, even when the configuration file
702 gives the default to color output.
703 Same as
<tt>--color=never
</tt>.
707 -[ABC]
<context
>
711 Show
<tt>context
</tt> trailing (
<tt>A
</tt> — after), or leading (
<tt>B
</tt>
712  — before), or both (
<tt>C
</tt> — context) lines, and place a
713 line containing
<tt>--
</tt> between contiguous groups of
722 A shortcut for specifying
<tt>-C
<num
></tt>.
733 Show the preceding line that contains the function name of
734 the match, unless the matching line is a function name itself.
735 The name is determined in the same way as
<em>git diff
</em> works out
736 patch hunk headers (see
<em>Defining a custom hunk-header
</em> in
737 <a href=
"gitattributes.html">gitattributes(
5)
</a>).
745 Read patterns from
<file
>, one per line.
753 The next parameter is the pattern. This option has to be
754 used for patterns starting with
<tt>-
</tt> and should be used in
755 scripts passing user input to grep. Multiple patterns are
756 combined by
<em>or
</em>.
773 Specify how multiple patterns are combined using Boolean
774 expressions.
<tt>--or
</tt> is the default operator.
<tt>--and
</tt> has
775 higher precedence than
<tt>--or
</tt>.
<tt>-e
</tt> has to be used for all
784 When giving multiple pattern expressions combined with
<tt>--or
</tt>,
785 this flag is specified to limit the match to files that
786 have lines to match all of them.
797 Do not output matched lines; instead, exit with status
0 when
798 there is a match and with non-zero status when there isn
’t.
806 Instead of searching tracked files in the working tree, search
807 blobs in the given trees.
815 Signals the end of options; the rest of the parameters
816 are
<pathspec
> limiters.
820 <pathspec
>…
824 If given, limit the search to paths matching at least one pattern.
825 Both leading paths match and glob(
7) patterns are supported.
830 <h2 id=
"_examples">Examples
</h2>
831 <div class=
"sectionbody">
832 <div class=
"dlist"><dl>
834 git grep
'time_t
' --
'*.[ch]
'
838 Looks for
<tt>time_t
</tt> in all tracked .c and .h files in the working
839 directory and its subdirectories.
843 git grep -e
'#define
' --and \( -e MAX_PATH -e PATH_MAX \)
847 Looks for a line that has
<tt>#define
</tt> and either
<tt>MAX_PATH
</tt> or
852 git grep --all-match -e NODE -e Unexpected
856 Looks for a line that has
<tt>NODE
</tt> or
<tt>Unexpected
</tt> in
857 files that have lines that match both.
862 <h2 id=
"_git">GIT
</h2>
863 <div class=
"sectionbody">
864 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
867 <div id=
"footer-text">
868 Last updated
2011-
05-
30 08:
13:
19 UTC