Documentation: a few spelling fixes
[git/git.git] / Documentation / git-grep.txt
CommitLineData
2aba319a
JH
1git-grep(1)
2===========
2aba319a
JH
3
4NAME
5----
5001422d 6git-grep - Print lines matching a pattern
2aba319a
JH
7
8
9SYNOPSIS
10--------
1c57119c
JH
11[verse]
12'git-grep' [--cached]
13 [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
17fd965d 14 [-v | --invert-match] [-h|-H] [--full-name]
07ea91d8 15 [-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings]
1c57119c 16 [-n] [-l | --files-with-matches] [-L | --files-without-match]
0ab7befa 17 [-c | --count] [--all-match]
1c57119c 18 [-A <post-context>] [-B <pre-context>] [-C <context>]
fba0cbd9 19 [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...]
1c57119c
JH
20 [<tree>...]
21 [--] [<path>...]
2aba319a
JH
22
23DESCRIPTION
24-----------
1c57119c
JH
25Look for specified patterns in the working tree files, blobs
26registered in the index file, or given tree objects.
2aba319a
JH
27
28
29OPTIONS
30-------
1c57119c
JH
31--cached::
32 Instead of searching in the working tree files, check
abda1ef5 33 the blobs registered in the index file.
1c57119c
JH
34
35-a | --text::
36 Process binary files as if they were text.
37
38-i | --ignore-case::
39 Ignore case differences between the patterns and the
40 files.
41
42-w | --word-regexp::
43 Match the pattern only at word boundary (either begin at the
44 beginning of a line, or preceded by a non-word character; end at
45 the end of a line or followed by a non-word character).
46
47-v | --invert-match::
48 Select non-matching lines.
49
17fd965d
JH
50-h | -H::
51 By default, the command shows the filename for each
52 match. `-h` option is used to suppress this output.
53 `-H` is there for completeness and does not do anything
54 except it overrides `-h` given earlier on the command
55 line.
56
0d042fec
JH
57--full-name::
58 When run from a subdirectory, the command usually
59 outputs paths relative to the current directory. This
60 option forces paths to be output relative to the project
61 top directory.
62
1c57119c
JH
63-E | --extended-regexp | -G | --basic-regexp::
64 Use POSIX extended/basic regexp for patterns. Default
65 is to use basic regexp.
5b2bcc7b 66
1c57119c
JH
67-n::
68 Prefix the line number to matching lines.
2aba319a 69
1c57119c
JH
70-l | --files-with-matches | -L | --files-without-match::
71 Instead of showing every matched line, show only the
72 names of files that contain (or do not contain) matches.
2aba319a 73
1c57119c
JH
74-c | --count::
75 Instead of showing every matched line, show the number of
76 lines that match.
77
78-[ABC] <context>::
79 Show `context` trailing (`A` -- after), or leading (`B`
80 -- before), or both (`C` -- context) lines, and place a
abda1ef5 81 line containing `--` between contiguous groups of
1c57119c
JH
82 matches.
83
84-f <file>::
85 Read patterns from <file>, one per line.
86
3acb27b6
ML
87-e::
88 The next parameter is the pattern. This option has to be
89 used for patterns starting with - and should be used in
fba0cbd9
ML
90 scripts passing user input to grep. Multiple patterns are
91 combined by 'or'.
92
93--and | --or | --not | ( | )::
23bfbb81 94 Specify how multiple patterns are combined using Boolean
fba0cbd9
ML
95 expressions. `--or` is the default operator. `--and` has
96 higher precedence than `--or`. `-e` has to be used for all
97 patterns.
3acb27b6 98
0ab7befa
JH
99--all-match::
100 When giving multiple pattern expressions combined with `--or`,
101 this flag is specified to limit the match to files that
102 have lines to match all of them.
103
1c57119c
JH
104`<tree>...`::
105 Search blobs in the trees for specified patterns.
106
fba0cbd9 107\--::
1c57119c
JH
108 Signals the end of options; the rest of the parameters
109 are <path> limiters.
2aba319a
JH
110
111
fba0cbd9
ML
112Example
113-------
114
115git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
116 Looks for a line that has `#define` and either `MAX_PATH` or
117 `PATH_MAX`.
118
0ab7befa
JH
119git grep --all-match -e NODE -e Unexpected::
120 Looks for a line that has `NODE` or `Unexpected` in
121 files that have lines that match both.
122
2aba319a
JH
123Author
124------
1c57119c
JH
125Originally written by Linus Torvalds <torvalds@osdl.org>, later
126revamped by Junio C Hamano.
127
2aba319a
JH
128
129Documentation
130--------------
131Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
132
133GIT
134---
a7154e91 135Part of the gitlink:git[7] suite
2aba319a 136