Autogenerated HTML docs for v1.7.6-549-gf85a0
[git/jnareb-git.git] / git-grep.html
bloba51a127d291f58f919edd99f219cd879b9fe028a
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 [-P | --perl-regexp]
422 [-F | --fixed-strings] [-n | --line-number]
423 [-l | --files-with-matches] [-L | --files-without-match]
424 [(-O | --open-files-in-pager) [&lt;pager&gt;]]
425 [-z | --null]
426 [-c | --count] [--all-match] [-q | --quiet]
427 [--max-depth &lt;depth&gt;]
428 [--color[=&lt;when&gt;] | --no-color]
429 [-A &lt;post-context&gt;] [-B &lt;pre-context&gt;] [-C &lt;context&gt;]
430 [-f &lt;file&gt;] [-e] &lt;pattern&gt;
431 [--and|--or|--not|(|)|-e &lt;pattern&gt;&#8230;]
432 [--cached | --no-index | &lt;tree&gt;&#8230;]
433 [--] [&lt;pathspec&gt;&#8230;]</div>
434 <div class="verseblock-attribution">
435 </div></div>
436 </div>
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>
441 </div>
442 <h2 id="_configuration">CONFIGURATION</h2>
443 <div class="sectionbody">
444 <div class="dlist"><dl>
445 <dt class="hdlist1">
446 grep.lineNumber
447 </dt>
448 <dd>
450 If set to true, enable <em>-n</em> option by default.
451 </p>
452 </dd>
453 <dt class="hdlist1">
454 grep.extendedRegexp
455 </dt>
456 <dd>
458 If set to true, enable <em>--extended-regexp</em> option by default.
459 </p>
460 </dd>
461 </dl></div>
462 </div>
463 <h2 id="_options">OPTIONS</h2>
464 <div class="sectionbody">
465 <div class="dlist"><dl>
466 <dt class="hdlist1">
467 --cached
468 </dt>
469 <dd>
471 Instead of searching tracked files in the working tree, search
472 blobs registered in the index file.
473 </p>
474 </dd>
475 <dt class="hdlist1">
476 --no-index
477 </dt>
478 <dd>
480 Search files in the current directory, not just those tracked by git.
481 </p>
482 </dd>
483 <dt class="hdlist1">
485 </dt>
486 <dt class="hdlist1">
487 --text
488 </dt>
489 <dd>
491 Process binary files as if they were text.
492 </p>
493 </dd>
494 <dt class="hdlist1">
496 </dt>
497 <dt class="hdlist1">
498 --ignore-case
499 </dt>
500 <dd>
502 Ignore case differences between the patterns and the
503 files.
504 </p>
505 </dd>
506 <dt class="hdlist1">
508 </dt>
509 <dd>
511 Don&#8217;t match the pattern in binary files.
512 </p>
513 </dd>
514 <dt class="hdlist1">
515 --max-depth &lt;depth&gt;
516 </dt>
517 <dd>
519 For each &lt;pathspec&gt; given on command line, descend at most &lt;depth&gt;
520 levels of directories. A negative value means no limit.
521 </p>
522 </dd>
523 <dt class="hdlist1">
525 </dt>
526 <dt class="hdlist1">
527 --word-regexp
528 </dt>
529 <dd>
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).
534 </p>
535 </dd>
536 <dt class="hdlist1">
538 </dt>
539 <dt class="hdlist1">
540 --invert-match
541 </dt>
542 <dd>
544 Select non-matching lines.
545 </p>
546 </dd>
547 <dt class="hdlist1">
549 </dt>
550 <dt class="hdlist1">
552 </dt>
553 <dd>
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
559 line.
560 </p>
561 </dd>
562 <dt class="hdlist1">
563 --full-name
564 </dt>
565 <dd>
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
570 top directory.
571 </p>
572 </dd>
573 <dt class="hdlist1">
575 </dt>
576 <dt class="hdlist1">
577 --extended-regexp
578 </dt>
579 <dt class="hdlist1">
581 </dt>
582 <dt class="hdlist1">
583 --basic-regexp
584 </dt>
585 <dd>
587 Use POSIX extended/basic regexp for patterns. Default
588 is to use basic regexp.
589 </p>
590 </dd>
591 <dt class="hdlist1">
593 </dt>
594 <dt class="hdlist1">
595 --perl-regexp
596 </dt>
597 <dd>
599 Use Perl-compatible regexp for patterns. Requires libpcre to be
600 compiled in.
601 </p>
602 </dd>
603 <dt class="hdlist1">
605 </dt>
606 <dt class="hdlist1">
607 --fixed-strings
608 </dt>
609 <dd>
611 Use fixed strings for patterns (don&#8217;t interpret pattern
612 as a regex).
613 </p>
614 </dd>
615 <dt class="hdlist1">
617 </dt>
618 <dt class="hdlist1">
619 --line-number
620 </dt>
621 <dd>
623 Prefix the line number to matching lines.
624 </p>
625 </dd>
626 <dt class="hdlist1">
628 </dt>
629 <dt class="hdlist1">
630 --files-with-matches
631 </dt>
632 <dt class="hdlist1">
633 --name-only
634 </dt>
635 <dt class="hdlist1">
637 </dt>
638 <dt class="hdlist1">
639 --files-without-match
640 </dt>
641 <dd>
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>.
647 </p>
648 </dd>
649 <dt class="hdlist1">
650 -O [&lt;pager&gt;]
651 </dt>
652 <dt class="hdlist1">
653 --open-files-in-pager [&lt;pager&gt;]
654 </dt>
655 <dd>
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.
661 </p>
662 </dd>
663 <dt class="hdlist1">
665 </dt>
666 <dt class="hdlist1">
667 --null
668 </dt>
669 <dd>
671 Output \0 instead of the character that normally follows a
672 file name.
673 </p>
674 </dd>
675 <dt class="hdlist1">
677 </dt>
678 <dt class="hdlist1">
679 --count
680 </dt>
681 <dd>
683 Instead of showing every matched line, show the number of
684 lines that match.
685 </p>
686 </dd>
687 <dt class="hdlist1">
688 --color[=&lt;when&gt;]
689 </dt>
690 <dd>
692 Show colored matches.
693 The value must be always (the default), never, or auto.
694 </p>
695 </dd>
696 <dt class="hdlist1">
697 --no-color
698 </dt>
699 <dd>
701 Turn off match highlighting, even when the configuration file
702 gives the default to color output.
703 Same as <tt>--color=never</tt>.
704 </p>
705 </dd>
706 <dt class="hdlist1">
707 --break
708 </dt>
709 <dd>
711 Print an empty line between matches from different files.
712 </p>
713 </dd>
714 <dt class="hdlist1">
715 --heading
716 </dt>
717 <dd>
719 Show the filename above the matches in that file instead of
720 at the start of each shown line.
721 </p>
722 </dd>
723 <dt class="hdlist1">
725 </dt>
726 <dt class="hdlist1">
727 --show-function
728 </dt>
729 <dd>
731 Show the preceding line that contains the function name of
732 the match, unless the matching line is a function name itself.
733 The name is determined in the same way as <em>git diff</em> works out
734 patch hunk headers (see <em>Defining a custom hunk-header</em> in
735 <a href="gitattributes.html">gitattributes(5)</a>).
736 </p>
737 </dd>
738 <dt class="hdlist1">
739 -&lt;num&gt;
740 </dt>
741 <dt class="hdlist1">
742 -C &lt;num&gt;
743 </dt>
744 <dt class="hdlist1">
745 --context &lt;num&gt;
746 </dt>
747 <dd>
749 Show &lt;num&gt; leading and trailing lines, and place a line
750 containing <tt>--</tt> between contiguous groups of matches.
751 </p>
752 </dd>
753 <dt class="hdlist1">
754 -A &lt;num&gt;
755 </dt>
756 <dt class="hdlist1">
757 --after-context &lt;num&gt;
758 </dt>
759 <dd>
761 Show &lt;num&gt; trailing lines, and place a line containing
762 <tt>--</tt> between contiguous groups of matches.
763 </p>
764 </dd>
765 <dt class="hdlist1">
766 -B &lt;num&gt;
767 </dt>
768 <dt class="hdlist1">
769 --before-context &lt;num&gt;
770 </dt>
771 <dd>
773 Show &lt;num&gt; leading lines, and place a line containing
774 <tt>--</tt> between contiguous groups of matches.
775 </p>
776 </dd>
777 <dt class="hdlist1">
779 </dt>
780 <dt class="hdlist1">
781 --function-context
782 </dt>
783 <dd>
785 Show the surrounding text from the previous line containing a
786 function name up to the one before the next function name,
787 effectively showing the whole function in which the match was
788 found.
789 </p>
790 </dd>
791 <dt class="hdlist1">
792 -f &lt;file&gt;
793 </dt>
794 <dd>
796 Read patterns from &lt;file&gt;, one per line.
797 </p>
798 </dd>
799 <dt class="hdlist1">
801 </dt>
802 <dd>
804 The next parameter is the pattern. This option has to be
805 used for patterns starting with <tt>-</tt> and should be used in
806 scripts passing user input to grep. Multiple patterns are
807 combined by <em>or</em>.
808 </p>
809 </dd>
810 <dt class="hdlist1">
811 --and
812 </dt>
813 <dt class="hdlist1">
814 --or
815 </dt>
816 <dt class="hdlist1">
817 --not
818 </dt>
819 <dt class="hdlist1">
820 ( &#8230; )
821 </dt>
822 <dd>
824 Specify how multiple patterns are combined using Boolean
825 expressions. <tt>--or</tt> is the default operator. <tt>--and</tt> has
826 higher precedence than <tt>--or</tt>. <tt>-e</tt> has to be used for all
827 patterns.
828 </p>
829 </dd>
830 <dt class="hdlist1">
831 --all-match
832 </dt>
833 <dd>
835 When giving multiple pattern expressions combined with <tt>--or</tt>,
836 this flag is specified to limit the match to files that
837 have lines to match all of them.
838 </p>
839 </dd>
840 <dt class="hdlist1">
842 </dt>
843 <dt class="hdlist1">
844 --quiet
845 </dt>
846 <dd>
848 Do not output matched lines; instead, exit with status 0 when
849 there is a match and with non-zero status when there isn&#8217;t.
850 </p>
851 </dd>
852 <dt class="hdlist1">
853 &lt;tree&gt;&#8230;
854 </dt>
855 <dd>
857 Instead of searching tracked files in the working tree, search
858 blobs in the given trees.
859 </p>
860 </dd>
861 <dt class="hdlist1">
863 </dt>
864 <dd>
866 Signals the end of options; the rest of the parameters
867 are &lt;pathspec&gt; limiters.
868 </p>
869 </dd>
870 <dt class="hdlist1">
871 &lt;pathspec&gt;&#8230;
872 </dt>
873 <dd>
875 If given, limit the search to paths matching at least one pattern.
876 Both leading paths match and glob(7) patterns are supported.
877 </p>
878 </dd>
879 </dl></div>
880 </div>
881 <h2 id="_examples">Examples</h2>
882 <div class="sectionbody">
883 <div class="dlist"><dl>
884 <dt class="hdlist1">
885 <tt>git grep &#39;time_t&#39; -- &#39;*.[ch]&#39;</tt>
886 </dt>
887 <dd>
889 Looks for <tt>time_t</tt> in all tracked .c and .h files in the working
890 directory and its subdirectories.
891 </p>
892 </dd>
893 <dt class="hdlist1">
894 <tt>git grep -e &#39;#define&#39; --and \( -e MAX_PATH -e PATH_MAX \)</tt>
895 </dt>
896 <dd>
898 Looks for a line that has <tt>#define</tt> and either <tt>MAX_PATH</tt> or
899 <tt>PATH_MAX</tt>.
900 </p>
901 </dd>
902 <dt class="hdlist1">
903 <tt>git grep --all-match -e NODE -e Unexpected</tt>
904 </dt>
905 <dd>
907 Looks for a line that has <tt>NODE</tt> or <tt>Unexpected</tt> in
908 files that have lines that match both.
909 </p>
910 </dd>
911 </dl></div>
912 </div>
913 <h2 id="_git">GIT</h2>
914 <div class="sectionbody">
915 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
916 </div>
917 <div id="footer">
918 <div id="footer-text">
919 Last updated 2011-08-11 22:26:57 UTC
920 </div>
921 </div>
922 </body>
923 </html>