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.5.2" />
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.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
247 list-style-type: upper-roman
;
250 div
.compact ul
, div
.compact ol
,
251 div
.compact p
, div
.compact p
,
252 div
.compact div
, div
.compact div
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
277 div
.tableblock
> table
[frame
="hsides"] {
278 border-left-style: none
;
279 border-right-style: none
;
281 div
.tableblock
> table
[frame
="vsides"] {
282 border-top-style: none
;
283 border-bottom-style: none
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
438 window
.onload = function(){asciidoc
.footnotes();}
439 var asciidoc
= { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
475 this.toclevel
= toclevel
;
478 function tocEntries(el
, toclevels
) {
479 var result
= new Array
;
480 var re
= new RegExp('[hH]([2-'+(toclevels
+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
484 var iterate = function (el
) {
485 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
486 if (i
.nodeType
== 1 /* Node.ELEMENT_NODE */) {
487 var mo
= re
.exec(i
.tagName
);
488 if (mo
&& (i
.getAttribute("class") || i
.getAttribute("className")) != "float") {
489 result
[result
.length
] = new TocEntry(i
, getText(i
), mo
[1]-1);
499 var toc
= document
.getElementById("toc");
500 var entries
= tocEntries(document
.getElementById("content"), toclevels
);
501 for (var i
= 0; i
< entries
.length
; ++i
) {
502 var entry
= entries
[i
];
503 if (entry
.element
.id
== "")
504 entry
.element
.id
= "_toc_" + i
;
505 var a
= document
.createElement("a");
506 a
.href
= "#" + entry
.element
.id
;
507 a
.appendChild(document
.createTextNode(entry
.text
));
508 var div
= document
.createElement("div");
510 div
.className
= "toclevel" + entry
.toclevel
;
511 toc
.appendChild(div
);
513 if (entries
.length
== 0)
514 toc
.parentNode
.removeChild(toc
);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont
= document
.getElementById("content");
528 var noteholder
= document
.getElementById("footnotes");
529 var spans
= cont
.getElementsByTagName("span");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note
= spans
[i
].innerHTML
.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder
.innerHTML
+=
539 "<div class='footnote' id='_footnote_" + n
+ "'>" +
540 "<a href='#_footnoteref_" + n
+ "' title='Return to text'>" +
541 n
+ "</a>. " + note
+ "</div>";
543 "[<a id='_footnoteref_" + n
+ "' href='#_footnote_" + n
+
544 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
545 var id
=spans
[i
].getAttribute("id");
546 if (id
!= null) refs
["#"+id
] = n
;
550 noteholder
.parentNode
.removeChild(noteholder
);
552 // Process footnoterefs.
553 for (i
=0; i
<spans
.length
; i
++) {
554 if (spans
[i
].className
== "footnoteref") {
555 var href
= spans
[i
].getElementsByTagName("a")[0].getAttribute("href");
556 href
= href
.match(/#.*/)[0]; // Because IE return full URL.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 git-grep(
1) Manual Page
576 <div class=
"sectionbody">
578 Print lines matching a pattern
583 <h2 id=
"_synopsis">SYNOPSIS
</h2>
584 <div class=
"sectionbody">
585 <div class=
"verseblock">
586 <div class=
"verseblock-content"><em>git grep
</em> [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
587 [-v | --invert-match] [-h|-H] [--full-name]
588 [-E | --extended-regexp] [-G | --basic-regexp]
590 [-F | --fixed-strings] [-n | --line-number]
591 [-l | --files-with-matches] [-L | --files-without-match]
592 [(-O | --open-files-in-pager) [
<pager
>]]
594 [-c | --count] [--all-match] [-q | --quiet]
595 [--max-depth
<depth
>]
596 [--color[=
<when
>] | --no-color]
597 [-A
<post-context
>] [-B
<pre-context
>] [-C
<context
>]
598 [-f
<file
>] [-e]
<pattern
>
599 [--and|--or|--not|(|)|-e
<pattern
>…]
600 [--cached | --no-index |
<tree
>…]
601 [--] [
<pathspec
>…]
</div>
602 <div class=
"verseblock-attribution">
605 <h2 id=
"_description">DESCRIPTION
</h2>
606 <div class=
"sectionbody">
607 <div class=
"paragraph"><p>Look for specified patterns in the tracked files in the work tree, blobs
608 registered in the index file, or blobs in given tree objects.
</p></div>
610 <h2 id=
"_configuration">CONFIGURATION
</h2>
611 <div class=
"sectionbody">
612 <div class=
"dlist"><dl>
618 If set to true, enable
<em>-n
</em> option by default.
626 If set to true, enable
<em>--extended-regexp
</em> option by default.
631 <h2 id=
"_options">OPTIONS
</h2>
632 <div class=
"sectionbody">
633 <div class=
"dlist"><dl>
639 Instead of searching tracked files in the working tree, search
640 blobs registered in the index file.
648 Search files in the current directory, not just those tracked by git.
659 Process binary files as if they were text.
670 Ignore case differences between the patterns and the
679 Don
’t match the pattern in binary files.
683 --max-depth
<depth
>
687 For each
<pathspec
> given on command line, descend at most
<depth
>
688 levels of directories. A negative value means no limit.
699 Match the pattern only at word boundary (either begin at the
700 beginning of a line, or preceded by a non-word character; end at
701 the end of a line or followed by a non-word character).
712 Select non-matching lines.
723 By default, the command shows the filename for each
724 match.
<tt>-h
</tt> option is used to suppress this output.
725 <tt>-H
</tt> is there for completeness and does not do anything
726 except it overrides
<tt>-h
</tt> given earlier on the command
735 When run from a subdirectory, the command usually
736 outputs paths relative to the current directory. This
737 option forces paths to be output relative to the project
755 Use POSIX extended/basic regexp for patterns. Default
756 is to use basic regexp.
767 Use Perl-compatible regexp for patterns. Requires libpcre to be
779 Use fixed strings for patterns (don
’t interpret pattern
791 Prefix the line number to matching lines.
807 --files-without-match
811 Instead of showing every matched line, show only the
812 names of files that contain (or do not contain) matches.
813 For better compatibility with
<em>git diff
</em>,
<tt>--name-only
</tt> is a
814 synonym for
<tt>--files-with-matches
</tt>.
821 --open-files-in-pager [
<pager
>]
825 Open the matching files in the pager (not the output of
<em>grep
</em>).
826 If the pager happens to be
"less" or
"vi", and the user
827 specified only one pattern, the first file is positioned at
828 the first match automatically.
839 Output \
0 instead of the character that normally follows a
851 Instead of showing every matched line, show the number of
856 --color[=
<when
>]
860 Show colored matches.
861 The value must be always (the default), never, or auto.
869 Turn off match highlighting, even when the configuration file
870 gives the default to color output.
871 Same as
<tt>--color=never
</tt>.
879 Print an empty line between matches from different files.
887 Show the filename above the matches in that file instead of
888 at the start of each shown line.
899 Show the preceding line that contains the function name of
900 the match, unless the matching line is a function name itself.
901 The name is determined in the same way as
<em>git diff
</em> works out
902 patch hunk headers (see
<em>Defining a custom hunk-header
</em> in
903 <a href=
"gitattributes.html">gitattributes(
5)
</a>).
913 --context
<num
>
917 Show
<num
> leading and trailing lines, and place a line
918 containing
<tt>--
</tt> between contiguous groups of matches.
925 --after-context
<num
>
929 Show
<num
> trailing lines, and place a line containing
930 <tt>--
</tt> between contiguous groups of matches.
937 --before-context
<num
>
941 Show
<num
> leading lines, and place a line containing
942 <tt>--
</tt> between contiguous groups of matches.
953 Show the surrounding text from the previous line containing a
954 function name up to the one before the next function name,
955 effectively showing the whole function in which the match was
964 Read patterns from
<file
>, one per line.
972 The next parameter is the pattern. This option has to be
973 used for patterns starting with
<tt>-
</tt> and should be used in
974 scripts passing user input to grep. Multiple patterns are
975 combined by
<em>or
</em>.
992 Specify how multiple patterns are combined using Boolean
993 expressions.
<tt>--or
</tt> is the default operator.
<tt>--and
</tt> has
994 higher precedence than
<tt>--or
</tt>.
<tt>-e
</tt> has to be used for all
1003 When giving multiple pattern expressions combined with
<tt>--or
</tt>,
1004 this flag is specified to limit the match to files that
1005 have lines to match all of them.
1008 <dt class=
"hdlist1">
1011 <dt class=
"hdlist1">
1016 Do not output matched lines; instead, exit with status
0 when
1017 there is a match and with non-zero status when there isn
’t.
1020 <dt class=
"hdlist1">
1025 Instead of searching tracked files in the working tree, search
1026 blobs in the given trees.
1029 <dt class=
"hdlist1">
1034 Signals the end of options; the rest of the parameters
1035 are
<pathspec
> limiters.
1038 <dt class=
"hdlist1">
1039 <pathspec
>…
1043 If given, limit the search to paths matching at least one pattern.
1044 Both leading paths match and glob(
7) patterns are supported.
1049 <h2 id=
"_examples">Examples
</h2>
1050 <div class=
"sectionbody">
1051 <div class=
"dlist"><dl>
1052 <dt class=
"hdlist1">
1053 <tt>git grep
'time_t
' --
'*.[ch]
'</tt>
1057 Looks for
<tt>time_t
</tt> in all tracked .c and .h files in the working
1058 directory and its subdirectories.
1061 <dt class=
"hdlist1">
1062 <tt>git grep -e
'#define
' --and \( -e MAX_PATH -e PATH_MAX \)
</tt>
1066 Looks for a line that has
<tt>#define
</tt> and either
<tt>MAX_PATH
</tt> or
1070 <dt class=
"hdlist1">
1071 <tt>git grep --all-match -e NODE -e Unexpected
</tt>
1075 Looks for a line that has
<tt>NODE
</tt> or
<tt>Unexpected
</tt> in
1076 files that have lines that match both.
1081 <h2 id=
"_git">GIT
</h2>
1082 <div class=
"sectionbody">
1083 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1086 <div id=
"footnotes"><hr /></div>
1088 <div id=
"footer-text">
1089 Last updated
2011-
09-
21 23:
01:
14 PDT