Autogenerated HTML docs for v1.7.6-rc1
[git/jnareb-git.git] / git-grep.html
blobe31c0070cde3b653f731a4f382407c1f144cc815
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 -[ABC] &lt;context&gt;
708 </dt>
709 <dd>
711 Show <tt>context</tt> trailing (<tt>A</tt>&#8201;&#8212;&#8201;after), or leading (<tt>B</tt>
712 &#8201;&#8212;&#8201;before), or both (<tt>C</tt>&#8201;&#8212;&#8201;context) lines, and place a
713 line containing <tt>--</tt> between contiguous groups of
714 matches.
715 </p>
716 </dd>
717 <dt class="hdlist1">
718 -&lt;num&gt;
719 </dt>
720 <dd>
722 A shortcut for specifying <tt>-C&lt;num&gt;</tt>.
723 </p>
724 </dd>
725 <dt class="hdlist1">
727 </dt>
728 <dt class="hdlist1">
729 --show-function
730 </dt>
731 <dd>
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>).
738 </p>
739 </dd>
740 <dt class="hdlist1">
741 -f &lt;file&gt;
742 </dt>
743 <dd>
745 Read patterns from &lt;file&gt;, one per line.
746 </p>
747 </dd>
748 <dt class="hdlist1">
750 </dt>
751 <dd>
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>.
757 </p>
758 </dd>
759 <dt class="hdlist1">
760 --and
761 </dt>
762 <dt class="hdlist1">
763 --or
764 </dt>
765 <dt class="hdlist1">
766 --not
767 </dt>
768 <dt class="hdlist1">
769 ( &#8230; )
770 </dt>
771 <dd>
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
776 patterns.
777 </p>
778 </dd>
779 <dt class="hdlist1">
780 --all-match
781 </dt>
782 <dd>
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.
787 </p>
788 </dd>
789 <dt class="hdlist1">
791 </dt>
792 <dt class="hdlist1">
793 --quiet
794 </dt>
795 <dd>
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&#8217;t.
799 </p>
800 </dd>
801 <dt class="hdlist1">
802 &lt;tree&gt;&#8230;
803 </dt>
804 <dd>
806 Instead of searching tracked files in the working tree, search
807 blobs in the given trees.
808 </p>
809 </dd>
810 <dt class="hdlist1">
812 </dt>
813 <dd>
815 Signals the end of options; the rest of the parameters
816 are &lt;pathspec&gt; limiters.
817 </p>
818 </dd>
819 <dt class="hdlist1">
820 &lt;pathspec&gt;&#8230;
821 </dt>
822 <dd>
824 If given, limit the search to paths matching at least one pattern.
825 Both leading paths match and glob(7) patterns are supported.
826 </p>
827 </dd>
828 </dl></div>
829 </div>
830 <h2 id="_examples">Examples</h2>
831 <div class="sectionbody">
832 <div class="dlist"><dl>
833 <dt class="hdlist1">
834 git grep &#39;time_t&#39; -- &#39;*.[ch]&#39;
835 </dt>
836 <dd>
838 Looks for <tt>time_t</tt> in all tracked .c and .h files in the working
839 directory and its subdirectories.
840 </p>
841 </dd>
842 <dt class="hdlist1">
843 git grep -e &#39;#define&#39; --and \( -e MAX_PATH -e PATH_MAX \)
844 </dt>
845 <dd>
847 Looks for a line that has <tt>#define</tt> and either <tt>MAX_PATH</tt> or
848 <tt>PATH_MAX</tt>.
849 </p>
850 </dd>
851 <dt class="hdlist1">
852 git grep --all-match -e NODE -e Unexpected
853 </dt>
854 <dd>
856 Looks for a line that has <tt>NODE</tt> or <tt>Unexpected</tt> in
857 files that have lines that match both.
858 </p>
859 </dd>
860 </dl></div>
861 </div>
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>
865 </div>
866 <div id="footer">
867 <div id="footer-text">
868 Last updated 2011-05-30 08:13:19 UTC
869 </div>
870 </div>
871 </body>
872 </html>