diff: fix textconv error zombies
[git/dscho.git] / Documentation / git-grep.txt
blobee506e67f09034591b4cd0215f72f61ff607d128
1 git-grep(1)
2 ===========
4 NAME
5 ----
6 git-grep - Print lines matching a pattern
9 SYNOPSIS
10 --------
11 [verse]
12 'git grep' [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
13            [-v | --invert-match] [-h|-H] [--full-name]
14            [-E | --extended-regexp] [-G | --basic-regexp]
15            [-F | --fixed-strings] [-n]
16            [-l | --files-with-matches] [-L | --files-without-match]
17            [-z | --null]
18            [-c | --count] [--all-match] [-q | --quiet]
19            [--max-depth <depth>]
20            [--color | --no-color]
21            [-A <post-context>] [-B <pre-context>] [-C <context>]
22            [-f <file>] [-e] <pattern>
23            [--and|--or|--not|(|)|-e <pattern>...]
24            [--cached | --no-index | <tree>...]
25            [--] [<pathspec>...]
27 DESCRIPTION
28 -----------
29 Look for specified patterns in the tracked files in the work tree, blobs
30 registered in the index file, or blobs in given tree objects.
33 OPTIONS
34 -------
35 --cached::
36         Instead of searching tracked files in the working tree, search
37         blobs registered in the index file.
39 --no-index::
40         Search files in the current directory, not just those tracked by git.
42 -a::
43 --text::
44         Process binary files as if they were text.
46 -i::
47 --ignore-case::
48         Ignore case differences between the patterns and the
49         files.
51 -I::
52         Don't match the pattern in binary files.
54 --max-depth <depth>::
55         For each <pathspec> given on command line, descend at most <depth>
56         levels of directories. A negative value means no limit.
58 -w::
59 --word-regexp::
60         Match the pattern only at word boundary (either begin at the
61         beginning of a line, or preceded by a non-word character; end at
62         the end of a line or followed by a non-word character).
64 -v::
65 --invert-match::
66         Select non-matching lines.
68 -h::
69 -H::
70         By default, the command shows the filename for each
71         match.  `-h` option is used to suppress this output.
72         `-H` is there for completeness and does not do anything
73         except it overrides `-h` given earlier on the command
74         line.
76 --full-name::
77         When run from a subdirectory, the command usually
78         outputs paths relative to the current directory.  This
79         option forces paths to be output relative to the project
80         top directory.
82 -E::
83 --extended-regexp::
84 -G::
85 --basic-regexp::
86         Use POSIX extended/basic regexp for patterns.  Default
87         is to use basic regexp.
89 -F::
90 --fixed-strings::
91         Use fixed strings for patterns (don't interpret pattern
92         as a regex).
94 -n::
95         Prefix the line number to matching lines.
97 -l::
98 --files-with-matches::
99 --name-only::
100 -L::
101 --files-without-match::
102         Instead of showing every matched line, show only the
103         names of files that contain (or do not contain) matches.
104         For better compatibility with 'git diff', `--name-only` is a
105         synonym for `--files-with-matches`.
107 -z::
108 --null::
109         Output \0 instead of the character that normally follows a
110         file name.
112 -c::
113 --count::
114         Instead of showing every matched line, show the number of
115         lines that match.
117 --color::
118         Show colored matches.
120 --no-color::
121         Turn off match highlighting, even when the configuration file
122         gives the default to color output.
124 -[ABC] <context>::
125         Show `context` trailing (`A` -- after), or leading (`B`
126         -- before), or both (`C` -- context) lines, and place a
127         line containing `--` between contiguous groups of
128         matches.
130 -<num>::
131         A shortcut for specifying `-C<num>`.
133 -p::
134 --show-function::
135         Show the preceding line that contains the function name of
136         the match, unless the matching line is a function name itself.
137         The name is determined in the same way as 'git diff' works out
138         patch hunk headers (see 'Defining a custom hunk-header' in
139         linkgit:gitattributes[5]).
141 -f <file>::
142         Read patterns from <file>, one per line.
144 -e::
145         The next parameter is the pattern. This option has to be
146         used for patterns starting with `-` and should be used in
147         scripts passing user input to grep.  Multiple patterns are
148         combined by 'or'.
150 --and::
151 --or::
152 --not::
153 ( ... )::
154         Specify how multiple patterns are combined using Boolean
155         expressions.  `--or` is the default operator.  `--and` has
156         higher precedence than `--or`.  `-e` has to be used for all
157         patterns.
159 --all-match::
160         When giving multiple pattern expressions combined with `--or`,
161         this flag is specified to limit the match to files that
162         have lines to match all of them.
164 -q::
165 --quiet::
166         Do not output matched lines; instead, exit with status 0 when
167         there is a match and with non-zero status when there isn't.
169 <tree>...::
170         Instead of searching tracked files in the working tree, search
171         blobs in the given trees.
173 \--::
174         Signals the end of options; the rest of the parameters
175         are <pathspec> limiters.
177 <pathspec>...::
178         If given, limit the search to paths matching at least one pattern.
179         Both leading paths match and glob(7) patterns are supported.
181 Examples
182 --------
184 git grep 'time_t' -- '*.[ch]'::
185         Looks for `time_t` in all tracked .c and .h files in the working
186         directory and its subdirectories.
188 git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
189         Looks for a line that has `#define` and either `MAX_PATH` or
190         `PATH_MAX`.
192 git grep --all-match -e NODE -e Unexpected::
193         Looks for a line that has `NODE` or `Unexpected` in
194         files that have lines that match both.
196 Author
197 ------
198 Originally written by Linus Torvalds <torvalds@osdl.org>, later
199 revamped by Junio C Hamano.
202 Documentation
203 --------------
204 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
208 Part of the linkgit:git[1] suite