Autogenerated HTML docs for v1.7.5.1-339-gb602ed
[git/jnareb-git.git] / git-grep.html
blob6da537e922ef598fa181eeb78f9856fb786114e7
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">
4 <head>
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">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.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 {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
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 {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
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;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-grep(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-grep -
411 Print lines matching a pattern
412 </p>
413 </div>
414 </div>
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) [&lt;pager&gt;]]
424 [-z | --null]
425 [-c | --count] [--all-match] [-q | --quiet]
426 [--max-depth &lt;depth&gt;]
427 [--color[=&lt;when&gt;] | --no-color]
428 [-A &lt;post-context&gt;] [-B &lt;pre-context&gt;] [-C &lt;context&gt;]
429 [-f &lt;file&gt;] [-e] &lt;pattern&gt;
430 [--and|--or|--not|(|)|-e &lt;pattern&gt;&#8230;]
431 [--cached | --no-index | &lt;tree&gt;&#8230;]
432 [--] [&lt;pathspec&gt;&#8230;]</div>
433 <div class="verseblock-attribution">
434 </div></div>
435 </div>
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>
440 </div>
441 <h2 id="_configuration">CONFIGURATION</h2>
442 <div class="sectionbody">
443 <div class="dlist"><dl>
444 <dt class="hdlist1">
445 grep.lineNumber
446 </dt>
447 <dd>
449 If set to true, enable <em>-n</em> option by default.
450 </p>
451 </dd>
452 <dt class="hdlist1">
453 grep.extendedRegexp
454 </dt>
455 <dd>
457 If set to true, enable <em>--extended-regexp</em> option by default.
458 </p>
459 </dd>
460 </dl></div>
461 </div>
462 <h2 id="_options">OPTIONS</h2>
463 <div class="sectionbody">
464 <div class="dlist"><dl>
465 <dt class="hdlist1">
466 --cached
467 </dt>
468 <dd>
470 Instead of searching tracked files in the working tree, search
471 blobs registered in the index file.
472 </p>
473 </dd>
474 <dt class="hdlist1">
475 --no-index
476 </dt>
477 <dd>
479 Search files in the current directory, not just those tracked by git.
480 </p>
481 </dd>
482 <dt class="hdlist1">
484 </dt>
485 <dt class="hdlist1">
486 --text
487 </dt>
488 <dd>
490 Process binary files as if they were text.
491 </p>
492 </dd>
493 <dt class="hdlist1">
495 </dt>
496 <dt class="hdlist1">
497 --ignore-case
498 </dt>
499 <dd>
501 Ignore case differences between the patterns and the
502 files.
503 </p>
504 </dd>
505 <dt class="hdlist1">
507 </dt>
508 <dd>
510 Don&#8217;t match the pattern in binary files.
511 </p>
512 </dd>
513 <dt class="hdlist1">
514 --max-depth &lt;depth&gt;
515 </dt>
516 <dd>
518 For each &lt;pathspec&gt; given on command line, descend at most &lt;depth&gt;
519 levels of directories. A negative value means no limit.
520 </p>
521 </dd>
522 <dt class="hdlist1">
524 </dt>
525 <dt class="hdlist1">
526 --word-regexp
527 </dt>
528 <dd>
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).
533 </p>
534 </dd>
535 <dt class="hdlist1">
537 </dt>
538 <dt class="hdlist1">
539 --invert-match
540 </dt>
541 <dd>
543 Select non-matching lines.
544 </p>
545 </dd>
546 <dt class="hdlist1">
548 </dt>
549 <dt class="hdlist1">
551 </dt>
552 <dd>
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
558 line.
559 </p>
560 </dd>
561 <dt class="hdlist1">
562 --full-name
563 </dt>
564 <dd>
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
569 top directory.
570 </p>
571 </dd>
572 <dt class="hdlist1">
574 </dt>
575 <dt class="hdlist1">
576 --extended-regexp
577 </dt>
578 <dt class="hdlist1">
580 </dt>
581 <dt class="hdlist1">
582 --basic-regexp
583 </dt>
584 <dd>
586 Use POSIX extended/basic regexp for patterns. Default
587 is to use basic regexp.
588 </p>
589 </dd>
590 <dt class="hdlist1">
592 </dt>
593 <dt class="hdlist1">
594 --fixed-strings
595 </dt>
596 <dd>
598 Use fixed strings for patterns (don&#8217;t interpret pattern
599 as a regex).
600 </p>
601 </dd>
602 <dt class="hdlist1">
604 </dt>
605 <dt class="hdlist1">
606 --line-number
607 </dt>
608 <dd>
610 Prefix the line number to matching lines.
611 </p>
612 </dd>
613 <dt class="hdlist1">
615 </dt>
616 <dt class="hdlist1">
617 --files-with-matches
618 </dt>
619 <dt class="hdlist1">
620 --name-only
621 </dt>
622 <dt class="hdlist1">
624 </dt>
625 <dt class="hdlist1">
626 --files-without-match
627 </dt>
628 <dd>
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>.
634 </p>
635 </dd>
636 <dt class="hdlist1">
637 -O [&lt;pager&gt;]
638 </dt>
639 <dt class="hdlist1">
640 --open-files-in-pager [&lt;pager&gt;]
641 </dt>
642 <dd>
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.
648 </p>
649 </dd>
650 <dt class="hdlist1">
652 </dt>
653 <dt class="hdlist1">
654 --null
655 </dt>
656 <dd>
658 Output \0 instead of the character that normally follows a
659 file name.
660 </p>
661 </dd>
662 <dt class="hdlist1">
664 </dt>
665 <dt class="hdlist1">
666 --count
667 </dt>
668 <dd>
670 Instead of showing every matched line, show the number of
671 lines that match.
672 </p>
673 </dd>
674 <dt class="hdlist1">
675 --color[=&lt;when&gt;]
676 </dt>
677 <dd>
679 Show colored matches.
680 The value must be always (the default), never, or auto.
681 </p>
682 </dd>
683 <dt class="hdlist1">
684 --no-color
685 </dt>
686 <dd>
688 Turn off match highlighting, even when the configuration file
689 gives the default to color output.
690 Same as <tt>--color=never</tt>.
691 </p>
692 </dd>
693 <dt class="hdlist1">
694 -[ABC] &lt;context&gt;
695 </dt>
696 <dd>
698 Show <tt>context</tt> trailing (<tt>A</tt>&#8201;&#8212;&#8201;after), or leading (<tt>B</tt>
699 &#8201;&#8212;&#8201;before), or both (<tt>C</tt>&#8201;&#8212;&#8201;context) lines, and place a
700 line containing <tt>--</tt> between contiguous groups of
701 matches.
702 </p>
703 </dd>
704 <dt class="hdlist1">
705 -&lt;num&gt;
706 </dt>
707 <dd>
709 A shortcut for specifying <tt>-C&lt;num&gt;</tt>.
710 </p>
711 </dd>
712 <dt class="hdlist1">
714 </dt>
715 <dt class="hdlist1">
716 --show-function
717 </dt>
718 <dd>
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>).
725 </p>
726 </dd>
727 <dt class="hdlist1">
728 -f &lt;file&gt;
729 </dt>
730 <dd>
732 Read patterns from &lt;file&gt;, one per line.
733 </p>
734 </dd>
735 <dt class="hdlist1">
737 </dt>
738 <dd>
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>.
744 </p>
745 </dd>
746 <dt class="hdlist1">
747 --and
748 </dt>
749 <dt class="hdlist1">
750 --or
751 </dt>
752 <dt class="hdlist1">
753 --not
754 </dt>
755 <dt class="hdlist1">
756 ( &#8230; )
757 </dt>
758 <dd>
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
763 patterns.
764 </p>
765 </dd>
766 <dt class="hdlist1">
767 --all-match
768 </dt>
769 <dd>
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.
774 </p>
775 </dd>
776 <dt class="hdlist1">
778 </dt>
779 <dt class="hdlist1">
780 --quiet
781 </dt>
782 <dd>
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&#8217;t.
786 </p>
787 </dd>
788 <dt class="hdlist1">
789 &lt;tree&gt;&#8230;
790 </dt>
791 <dd>
793 Instead of searching tracked files in the working tree, search
794 blobs in the given trees.
795 </p>
796 </dd>
797 <dt class="hdlist1">
799 </dt>
800 <dd>
802 Signals the end of options; the rest of the parameters
803 are &lt;pathspec&gt; limiters.
804 </p>
805 </dd>
806 <dt class="hdlist1">
807 &lt;pathspec&gt;&#8230;
808 </dt>
809 <dd>
811 If given, limit the search to paths matching at least one pattern.
812 Both leading paths match and glob(7) patterns are supported.
813 </p>
814 </dd>
815 </dl></div>
816 </div>
817 <h2 id="_examples">Examples</h2>
818 <div class="sectionbody">
819 <div class="dlist"><dl>
820 <dt class="hdlist1">
821 git grep &#39;time_t&#39; -- &#39;*.[ch]&#39;
822 </dt>
823 <dd>
825 Looks for <tt>time_t</tt> in all tracked .c and .h files in the working
826 directory and its subdirectories.
827 </p>
828 </dd>
829 <dt class="hdlist1">
830 git grep -e &#39;#define&#39; --and \( -e MAX_PATH -e PATH_MAX \)
831 </dt>
832 <dd>
834 Looks for a line that has <tt>#define</tt> and either <tt>MAX_PATH</tt> or
835 <tt>PATH_MAX</tt>.
836 </p>
837 </dd>
838 <dt class="hdlist1">
839 git grep --all-match -e NODE -e Unexpected
840 </dt>
841 <dd>
843 Looks for a line that has <tt>NODE</tt> or <tt>Unexpected</tt> in
844 files that have lines that match both.
845 </p>
846 </dd>
847 </dl></div>
848 </div>
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>
852 </div>
853 <div id="footer">
854 <div id="footer-text">
855 Last updated 2011-04-02 04:31:58 UTC
856 </div>
857 </div>
858 </body>
859 </html>