Autogenerated HTML docs for v1.7.4.2-414-g07514
[git/jnareb-git.git] / git-grep.html
blob76e110b09f8448d11c51da5df2d56d31cf03b4a5
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="_options">OPTIONS</h2>
442 <div class="sectionbody">
443 <div class="dlist"><dl>
444 <dt class="hdlist1">
445 --cached
446 </dt>
447 <dd>
449 Instead of searching tracked files in the working tree, search
450 blobs registered in the index file.
451 </p>
452 </dd>
453 <dt class="hdlist1">
454 --no-index
455 </dt>
456 <dd>
458 Search files in the current directory, not just those tracked by git.
459 </p>
460 </dd>
461 <dt class="hdlist1">
463 </dt>
464 <dt class="hdlist1">
465 --text
466 </dt>
467 <dd>
469 Process binary files as if they were text.
470 </p>
471 </dd>
472 <dt class="hdlist1">
474 </dt>
475 <dt class="hdlist1">
476 --ignore-case
477 </dt>
478 <dd>
480 Ignore case differences between the patterns and the
481 files.
482 </p>
483 </dd>
484 <dt class="hdlist1">
486 </dt>
487 <dd>
489 Don&#8217;t match the pattern in binary files.
490 </p>
491 </dd>
492 <dt class="hdlist1">
493 --max-depth &lt;depth&gt;
494 </dt>
495 <dd>
497 For each &lt;pathspec&gt; given on command line, descend at most &lt;depth&gt;
498 levels of directories. A negative value means no limit.
499 </p>
500 </dd>
501 <dt class="hdlist1">
503 </dt>
504 <dt class="hdlist1">
505 --word-regexp
506 </dt>
507 <dd>
509 Match the pattern only at word boundary (either begin at the
510 beginning of a line, or preceded by a non-word character; end at
511 the end of a line or followed by a non-word character).
512 </p>
513 </dd>
514 <dt class="hdlist1">
516 </dt>
517 <dt class="hdlist1">
518 --invert-match
519 </dt>
520 <dd>
522 Select non-matching lines.
523 </p>
524 </dd>
525 <dt class="hdlist1">
527 </dt>
528 <dt class="hdlist1">
530 </dt>
531 <dd>
533 By default, the command shows the filename for each
534 match. <tt>-h</tt> option is used to suppress this output.
535 <tt>-H</tt> is there for completeness and does not do anything
536 except it overrides <tt>-h</tt> given earlier on the command
537 line.
538 </p>
539 </dd>
540 <dt class="hdlist1">
541 --full-name
542 </dt>
543 <dd>
545 When run from a subdirectory, the command usually
546 outputs paths relative to the current directory. This
547 option forces paths to be output relative to the project
548 top directory.
549 </p>
550 </dd>
551 <dt class="hdlist1">
553 </dt>
554 <dt class="hdlist1">
555 --extended-regexp
556 </dt>
557 <dt class="hdlist1">
559 </dt>
560 <dt class="hdlist1">
561 --basic-regexp
562 </dt>
563 <dd>
565 Use POSIX extended/basic regexp for patterns. Default
566 is to use basic regexp.
567 </p>
568 </dd>
569 <dt class="hdlist1">
571 </dt>
572 <dt class="hdlist1">
573 --fixed-strings
574 </dt>
575 <dd>
577 Use fixed strings for patterns (don&#8217;t interpret pattern
578 as a regex).
579 </p>
580 </dd>
581 <dt class="hdlist1">
583 </dt>
584 <dt class="hdlist1">
585 --line-number
586 </dt>
587 <dd>
589 Prefix the line number to matching lines.
590 </p>
591 </dd>
592 <dt class="hdlist1">
594 </dt>
595 <dt class="hdlist1">
596 --files-with-matches
597 </dt>
598 <dt class="hdlist1">
599 --name-only
600 </dt>
601 <dt class="hdlist1">
603 </dt>
604 <dt class="hdlist1">
605 --files-without-match
606 </dt>
607 <dd>
609 Instead of showing every matched line, show only the
610 names of files that contain (or do not contain) matches.
611 For better compatibility with <em>git diff</em>, <tt>--name-only</tt> is a
612 synonym for <tt>--files-with-matches</tt>.
613 </p>
614 </dd>
615 <dt class="hdlist1">
616 -O [&lt;pager&gt;]
617 </dt>
618 <dt class="hdlist1">
619 --open-files-in-pager [&lt;pager&gt;]
620 </dt>
621 <dd>
623 Open the matching files in the pager (not the output of <em>grep</em>).
624 If the pager happens to be "less" or "vi", and the user
625 specified only one pattern, the first file is positioned at
626 the first match automatically.
627 </p>
628 </dd>
629 <dt class="hdlist1">
631 </dt>
632 <dt class="hdlist1">
633 --null
634 </dt>
635 <dd>
637 Output \0 instead of the character that normally follows a
638 file name.
639 </p>
640 </dd>
641 <dt class="hdlist1">
643 </dt>
644 <dt class="hdlist1">
645 --count
646 </dt>
647 <dd>
649 Instead of showing every matched line, show the number of
650 lines that match.
651 </p>
652 </dd>
653 <dt class="hdlist1">
654 --color[=&lt;when&gt;]
655 </dt>
656 <dd>
658 Show colored matches.
659 The value must be always (the default), never, or auto.
660 </p>
661 </dd>
662 <dt class="hdlist1">
663 --no-color
664 </dt>
665 <dd>
667 Turn off match highlighting, even when the configuration file
668 gives the default to color output.
669 Same as <tt>--color=never</tt>.
670 </p>
671 </dd>
672 <dt class="hdlist1">
673 -[ABC] &lt;context&gt;
674 </dt>
675 <dd>
677 Show <tt>context</tt> trailing (<tt>A</tt>&#8201;&#8212;&#8201;after), or leading (<tt>B</tt>
678 &#8201;&#8212;&#8201;before), or both (<tt>C</tt>&#8201;&#8212;&#8201;context) lines, and place a
679 line containing <tt>--</tt> between contiguous groups of
680 matches.
681 </p>
682 </dd>
683 <dt class="hdlist1">
684 -&lt;num&gt;
685 </dt>
686 <dd>
688 A shortcut for specifying <tt>-C&lt;num&gt;</tt>.
689 </p>
690 </dd>
691 <dt class="hdlist1">
693 </dt>
694 <dt class="hdlist1">
695 --show-function
696 </dt>
697 <dd>
699 Show the preceding line that contains the function name of
700 the match, unless the matching line is a function name itself.
701 The name is determined in the same way as <em>git diff</em> works out
702 patch hunk headers (see <em>Defining a custom hunk-header</em> in
703 <a href="gitattributes.html">gitattributes(5)</a>).
704 </p>
705 </dd>
706 <dt class="hdlist1">
707 -f &lt;file&gt;
708 </dt>
709 <dd>
711 Read patterns from &lt;file&gt;, one per line.
712 </p>
713 </dd>
714 <dt class="hdlist1">
716 </dt>
717 <dd>
719 The next parameter is the pattern. This option has to be
720 used for patterns starting with <tt>-</tt> and should be used in
721 scripts passing user input to grep. Multiple patterns are
722 combined by <em>or</em>.
723 </p>
724 </dd>
725 <dt class="hdlist1">
726 --and
727 </dt>
728 <dt class="hdlist1">
729 --or
730 </dt>
731 <dt class="hdlist1">
732 --not
733 </dt>
734 <dt class="hdlist1">
735 ( &#8230; )
736 </dt>
737 <dd>
739 Specify how multiple patterns are combined using Boolean
740 expressions. <tt>--or</tt> is the default operator. <tt>--and</tt> has
741 higher precedence than <tt>--or</tt>. <tt>-e</tt> has to be used for all
742 patterns.
743 </p>
744 </dd>
745 <dt class="hdlist1">
746 --all-match
747 </dt>
748 <dd>
750 When giving multiple pattern expressions combined with <tt>--or</tt>,
751 this flag is specified to limit the match to files that
752 have lines to match all of them.
753 </p>
754 </dd>
755 <dt class="hdlist1">
757 </dt>
758 <dt class="hdlist1">
759 --quiet
760 </dt>
761 <dd>
763 Do not output matched lines; instead, exit with status 0 when
764 there is a match and with non-zero status when there isn&#8217;t.
765 </p>
766 </dd>
767 <dt class="hdlist1">
768 &lt;tree&gt;&#8230;
769 </dt>
770 <dd>
772 Instead of searching tracked files in the working tree, search
773 blobs in the given trees.
774 </p>
775 </dd>
776 <dt class="hdlist1">
778 </dt>
779 <dd>
781 Signals the end of options; the rest of the parameters
782 are &lt;pathspec&gt; limiters.
783 </p>
784 </dd>
785 <dt class="hdlist1">
786 &lt;pathspec&gt;&#8230;
787 </dt>
788 <dd>
790 If given, limit the search to paths matching at least one pattern.
791 Both leading paths match and glob(7) patterns are supported.
792 </p>
793 </dd>
794 </dl></div>
795 </div>
796 <h2 id="_examples">Examples</h2>
797 <div class="sectionbody">
798 <div class="dlist"><dl>
799 <dt class="hdlist1">
800 git grep &#39;time_t&#39; -- &#39;*.[ch]&#39;
801 </dt>
802 <dd>
804 Looks for <tt>time_t</tt> in all tracked .c and .h files in the working
805 directory and its subdirectories.
806 </p>
807 </dd>
808 <dt class="hdlist1">
809 git grep -e &#39;#define&#39; --and \( -e MAX_PATH -e PATH_MAX \)
810 </dt>
811 <dd>
813 Looks for a line that has <tt>#define</tt> and either <tt>MAX_PATH</tt> or
814 <tt>PATH_MAX</tt>.
815 </p>
816 </dd>
817 <dt class="hdlist1">
818 git grep --all-match -e NODE -e Unexpected
819 </dt>
820 <dd>
822 Looks for a line that has <tt>NODE</tt> or <tt>Unexpected</tt> in
823 files that have lines that match both.
824 </p>
825 </dd>
826 </dl></div>
827 </div>
828 <h2 id="_git">GIT</h2>
829 <div class="sectionbody">
830 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
831 </div>
832 <div id="footer">
833 <div id="footer-text">
834 Last updated 2011-03-29 06:53:36 UTC
835 </div>
836 </div>
837 </body>
838 </html>