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 [ [--exclude-standard] [--cached | --no-index | --untracked] |
<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 that is not managed by git.
656 In addition to searching in the tracked files in the working
657 tree, search also in untracked files.
661 --no-exclude-standard
665 Also search in ignored files by not honoring the
<tt>.gitignore
</tt>
666 mechanism. Only useful with
<tt>--untracked
</tt>.
674 Do not pay attention to ignored files specified via the
<tt>.gitignore
</tt>
675 mechanism. Only useful when searching files in the current directory
676 with
<tt>--no-index
</tt>.
687 Process binary files as if they were text.
698 Ignore case differences between the patterns and the
707 Don
’t match the pattern in binary files.
711 --max-depth
<depth
>
715 For each
<pathspec
> given on command line, descend at most
<depth
>
716 levels of directories. A negative value means no limit.
727 Match the pattern only at word boundary (either begin at the
728 beginning of a line, or preceded by a non-word character; end at
729 the end of a line or followed by a non-word character).
740 Select non-matching lines.
751 By default, the command shows the filename for each
752 match.
<tt>-h
</tt> option is used to suppress this output.
753 <tt>-H
</tt> is there for completeness and does not do anything
754 except it overrides
<tt>-h
</tt> given earlier on the command
763 When run from a subdirectory, the command usually
764 outputs paths relative to the current directory. This
765 option forces paths to be output relative to the project
783 Use POSIX extended/basic regexp for patterns. Default
784 is to use basic regexp.
795 Use Perl-compatible regexp for patterns. Requires libpcre to be
807 Use fixed strings for patterns (don
’t interpret pattern
819 Prefix the line number to matching lines.
835 --files-without-match
839 Instead of showing every matched line, show only the
840 names of files that contain (or do not contain) matches.
841 For better compatibility with
<em>git diff
</em>,
<tt>--name-only
</tt> is a
842 synonym for
<tt>--files-with-matches
</tt>.
849 --open-files-in-pager [
<pager
>]
853 Open the matching files in the pager (not the output of
<em>grep
</em>).
854 If the pager happens to be
"less" or
"vi", and the user
855 specified only one pattern, the first file is positioned at
856 the first match automatically.
867 Output \
0 instead of the character that normally follows a
879 Instead of showing every matched line, show the number of
884 --color[=
<when
>]
888 Show colored matches.
889 The value must be always (the default), never, or auto.
897 Turn off match highlighting, even when the configuration file
898 gives the default to color output.
899 Same as
<tt>--color=never
</tt>.
907 Print an empty line between matches from different files.
915 Show the filename above the matches in that file instead of
916 at the start of each shown line.
927 Show the preceding line that contains the function name of
928 the match, unless the matching line is a function name itself.
929 The name is determined in the same way as
<em>git diff
</em> works out
930 patch hunk headers (see
<em>Defining a custom hunk-header
</em> in
931 <a href=
"gitattributes.html">gitattributes(
5)
</a>).
941 --context
<num
>
945 Show
<num
> leading and trailing lines, and place a line
946 containing
<tt>--
</tt> between contiguous groups of matches.
953 --after-context
<num
>
957 Show
<num
> trailing lines, and place a line containing
958 <tt>--
</tt> between contiguous groups of matches.
965 --before-context
<num
>
969 Show
<num
> leading lines, and place a line containing
970 <tt>--
</tt> between contiguous groups of matches.
981 Show the surrounding text from the previous line containing a
982 function name up to the one before the next function name,
983 effectively showing the whole function in which the match was
992 Read patterns from
<file
>, one per line.
1000 The next parameter is the pattern. This option has to be
1001 used for patterns starting with
<tt>-
</tt> and should be used in
1002 scripts passing user input to grep. Multiple patterns are
1003 combined by
<em>or
</em>.
1006 <dt class=
"hdlist1">
1009 <dt class=
"hdlist1">
1012 <dt class=
"hdlist1">
1015 <dt class=
"hdlist1">
1020 Specify how multiple patterns are combined using Boolean
1021 expressions.
<tt>--or
</tt> is the default operator.
<tt>--and
</tt> has
1022 higher precedence than
<tt>--or
</tt>.
<tt>-e
</tt> has to be used for all
1026 <dt class=
"hdlist1">
1031 When giving multiple pattern expressions combined with
<tt>--or
</tt>,
1032 this flag is specified to limit the match to files that
1033 have lines to match all of them.
1036 <dt class=
"hdlist1">
1039 <dt class=
"hdlist1">
1044 Do not output matched lines; instead, exit with status
0 when
1045 there is a match and with non-zero status when there isn
’t.
1048 <dt class=
"hdlist1">
1053 Instead of searching tracked files in the working tree, search
1054 blobs in the given trees.
1057 <dt class=
"hdlist1">
1062 Signals the end of options; the rest of the parameters
1063 are
<pathspec
> limiters.
1066 <dt class=
"hdlist1">
1067 <pathspec
>…
1071 If given, limit the search to paths matching at least one pattern.
1072 Both leading paths match and glob(
7) patterns are supported.
1077 <h2 id=
"_examples">Examples
</h2>
1078 <div class=
"sectionbody">
1079 <div class=
"dlist"><dl>
1080 <dt class=
"hdlist1">
1081 <tt>git grep
'time_t
' --
'*.[ch]
'</tt>
1085 Looks for
<tt>time_t
</tt> in all tracked .c and .h files in the working
1086 directory and its subdirectories.
1089 <dt class=
"hdlist1">
1090 <tt>git grep -e
'#define
' --and \( -e MAX_PATH -e PATH_MAX \)
</tt>
1094 Looks for a line that has
<tt>#define
</tt> and either
<tt>MAX_PATH
</tt> or
1098 <dt class=
"hdlist1">
1099 <tt>git grep --all-match -e NODE -e Unexpected
</tt>
1103 Looks for a line that has
<tt>NODE
</tt> or
<tt>Unexpected
</tt> in
1104 files that have lines that match both.
1109 <h2 id=
"_git">GIT
</h2>
1110 <div class=
"sectionbody">
1111 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1114 <div id=
"footnotes"><hr /></div>
1116 <div id=
"footer-text">
1117 Last updated
2011-
10-
13 22:
57:
58 PDT