1GIT-GREP(1)                       Git Manual                       GIT-GREP(1)
2
3
4

NAME

6       git-grep - Print lines matching a pattern
7

SYNOPSIS

9           git-grep [--cached]
10                      [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
11                      [-v | --invert-match] [-h|-H] [--full-name]
12                      [-E | --extended-regexp] [-G | --basic-regexp]
13                      [-F | --fixed-strings] [-n]
14                      [-l | --files-with-matches] [-L | --files-without-match]
15                      [-c | --count] [--all-match]
16                      [-A <post-context>] [-B <pre-context>] [-C <context>]
17                      [-f <file>] [-e] <pattern>
18                      [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
19                      [--] [<path>...]
20

DESCRIPTION

22       Look for specified patterns in the working tree files, blobs registered
23       in the index file, or given tree objects.
24

OPTIONS

26       --cached
27           Instead of searching in the working tree files, check the blobs
28           registered in the index file.
29
30       -a | --text
31           Process binary files as if they were text.
32
33       -i | --ignore-case
34           Ignore case differences between the patterns and the files.
35
36       -I
37           Don´t match the pattern in binary files.
38
39       -w | --word-regexp
40           Match the pattern only at word boundary (either begin at the
41           beginning of a line, or preceded by a non-word character; end at
42           the end of a line or followed by a non-word character).
43
44       -v | --invert-match
45           Select non-matching lines.
46
47       -h | -H
48           By default, the command shows the filename for each match. -h
49           option is used to suppress this output. -H is there for
50           completeness and does not do anything except it overrides -h given
51           earlier on the command line.
52
53       --full-name
54           When run from a subdirectory, the command usually outputs paths
55           relative to the current directory. This option forces paths to be
56           output relative to the project top directory.
57
58       -E | --extended-regexp | -G | --basic-regexp
59           Use POSIX extended/basic regexp for patterns. Default is to use
60           basic regexp.
61
62       -F | --fixed-strings
63           Use fixed strings for patterns (don´t interpret pattern as a
64           regex).
65
66       -n
67           Prefix the line number to matching lines.
68
69       -l | --files-with-matches | -L | --files-without-match
70           Instead of showing every matched line, show only the names of files
71           that contain (or do not contain) matches.
72
73       -c | --count
74           Instead of showing every matched line, show the number of lines
75           that match.
76
77       -[ABC] <context>
78           Show context trailing (A — after), or leading (B — before), or both
79           (C — context) lines, and place a line containing -- between
80           contiguous groups of matches.
81
82       -<num>
83           A shortcut for specifying -C<num>.
84
85       -f <file>
86           Read patterns from <file>, one per line.
87
88       -e
89           The next parameter is the pattern. This option has to be used for
90           patterns starting with - and should be used in scripts passing user
91           input to grep. Multiple patterns are combined by or.
92
93       --and | --or | --not | ( | )
94           Specify how multiple patterns are combined using Boolean
95           expressions. --or is the default operator. --and has higher
96           precedence than --or. -e has to be used for all patterns.
97
98       --all-match
99           When giving multiple pattern expressions combined with --or, this
100           flag is specified to limit the match to files that have lines to
101           match all of them.
102
103       <tree>...
104           Search blobs in the trees for specified patterns.
105
106       --
107           Signals the end of options; the rest of the parameters are <path>
108           limiters.
109

EXAMPLE

111       git grep -e ´#define´ --and \( -e MAX_PATH -e PATH_MAX \)
112           Looks for a line that has #define and either MAX_PATH or PATH_MAX.
113
114       git grep --all-match -e NODE -e Unexpected
115           Looks for a line that has NODE or Unexpected in files that have
116           lines that match both.
117

AUTHOR

119       Originally written by Linus Torvalds <torvalds@osdl.org>, later
120       revamped by Junio C Hamano.
121

DOCUMENTATION

123       Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
124

GIT

126       Part of the git(7) suite
127
128
129
130
131Git 1.5.3.3                       10/09/2007                       GIT-GREP(1)
Impressum