2005-09-13 04:39:15 +02:00
|
|
|
git-grep(1)
|
|
|
|
===========
|
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2006-03-09 17:24:37 +01:00
|
|
|
git-grep - Print lines matching a pattern
|
2005-09-13 04:39:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2006-05-08 22:28:49 +02:00
|
|
|
[verse]
|
|
|
|
'git-grep' [--cached]
|
|
|
|
[-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
|
2006-09-16 03:37:01 +02:00
|
|
|
[-v | --invert-match] [-h|-H] [--full-name]
|
2006-05-10 03:28:41 +02:00
|
|
|
[-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings]
|
2006-05-08 22:28:49 +02:00
|
|
|
[-n] [-l | --files-with-matches] [-L | --files-without-match]
|
|
|
|
[-c | --count]
|
|
|
|
[-A <post-context>] [-B <pre-context>] [-C <context>]
|
2006-08-03 00:04:56 +02:00
|
|
|
[-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...]
|
2006-05-08 22:28:49 +02:00
|
|
|
[<tree>...]
|
|
|
|
[--] [<path>...]
|
2005-09-13 04:39:15 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
2006-05-08 22:28:49 +02:00
|
|
|
Look for specified patterns in the working tree files, blobs
|
|
|
|
registered in the index file, or given tree objects.
|
2005-09-13 04:39:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-------
|
2006-05-08 22:28:49 +02:00
|
|
|
--cached::
|
|
|
|
Instead of searching in the working tree files, check
|
2006-06-03 22:27:26 +02:00
|
|
|
the blobs registered in the index file.
|
2006-05-08 22:28:49 +02:00
|
|
|
|
|
|
|
-a | --text::
|
|
|
|
Process binary files as if they were text.
|
|
|
|
|
|
|
|
-i | --ignore-case::
|
|
|
|
Ignore case differences between the patterns and the
|
|
|
|
files.
|
|
|
|
|
|
|
|
-w | --word-regexp::
|
|
|
|
Match the pattern only at word boundary (either begin at the
|
|
|
|
beginning of a line, or preceded by a non-word character; end at
|
|
|
|
the end of a line or followed by a non-word character).
|
|
|
|
|
|
|
|
-v | --invert-match::
|
|
|
|
Select non-matching lines.
|
|
|
|
|
2006-09-16 03:37:01 +02:00
|
|
|
-h | -H::
|
|
|
|
By default, the command shows the filename for each
|
|
|
|
match. `-h` option is used to suppress this output.
|
|
|
|
`-H` is there for completeness and does not do anything
|
|
|
|
except it overrides `-h` given earlier on the command
|
|
|
|
line.
|
|
|
|
|
2006-08-11 09:44:42 +02:00
|
|
|
--full-name::
|
|
|
|
When run from a subdirectory, the command usually
|
|
|
|
outputs paths relative to the current directory. This
|
|
|
|
option forces paths to be output relative to the project
|
|
|
|
top directory.
|
|
|
|
|
2006-05-08 22:28:49 +02:00
|
|
|
-E | --extended-regexp | -G | --basic-regexp::
|
|
|
|
Use POSIX extended/basic regexp for patterns. Default
|
|
|
|
is to use basic regexp.
|
2006-01-21 00:00:12 +01:00
|
|
|
|
2006-05-08 22:28:49 +02:00
|
|
|
-n::
|
|
|
|
Prefix the line number to matching lines.
|
2005-09-13 04:39:15 +02:00
|
|
|
|
2006-05-08 22:28:49 +02:00
|
|
|
-l | --files-with-matches | -L | --files-without-match::
|
|
|
|
Instead of showing every matched line, show only the
|
|
|
|
names of files that contain (or do not contain) matches.
|
2005-09-13 04:39:15 +02:00
|
|
|
|
2006-05-08 22:28:49 +02:00
|
|
|
-c | --count::
|
|
|
|
Instead of showing every matched line, show the number of
|
|
|
|
lines that match.
|
|
|
|
|
|
|
|
-[ABC] <context>::
|
|
|
|
Show `context` trailing (`A` -- after), or leading (`B`
|
|
|
|
-- before), or both (`C` -- context) lines, and place a
|
2006-06-03 22:27:26 +02:00
|
|
|
line containing `--` between contiguous groups of
|
2006-05-08 22:28:49 +02:00
|
|
|
matches.
|
|
|
|
|
|
|
|
-f <file>::
|
|
|
|
Read patterns from <file>, one per line.
|
|
|
|
|
2006-06-25 18:07:15 +02:00
|
|
|
-e::
|
|
|
|
The next parameter is the pattern. This option has to be
|
|
|
|
used for patterns starting with - and should be used in
|
2006-08-03 00:04:56 +02:00
|
|
|
scripts passing user input to grep. Multiple patterns are
|
|
|
|
combined by 'or'.
|
|
|
|
|
|
|
|
--and | --or | --not | ( | )::
|
|
|
|
Specify how multiple patterns are combined using boolean
|
|
|
|
expressions. `--or` is the default operator. `--and` has
|
|
|
|
higher precedence than `--or`. `-e` has to be used for all
|
|
|
|
patterns.
|
2006-06-25 18:07:15 +02:00
|
|
|
|
2006-05-08 22:28:49 +02:00
|
|
|
`<tree>...`::
|
|
|
|
Search blobs in the trees for specified patterns.
|
|
|
|
|
2006-08-03 00:04:56 +02:00
|
|
|
\--::
|
2006-05-08 22:28:49 +02:00
|
|
|
Signals the end of options; the rest of the parameters
|
|
|
|
are <path> limiters.
|
2005-09-13 04:39:15 +02:00
|
|
|
|
|
|
|
|
2006-08-03 00:04:56 +02:00
|
|
|
Example
|
|
|
|
-------
|
|
|
|
|
|
|
|
git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
|
|
|
|
Looks for a line that has `#define` and either `MAX_PATH` or
|
|
|
|
`PATH_MAX`.
|
|
|
|
|
2005-09-13 04:39:15 +02:00
|
|
|
Author
|
|
|
|
------
|
2006-05-08 22:28:49 +02:00
|
|
|
Originally written by Linus Torvalds <torvalds@osdl.org>, later
|
|
|
|
revamped by Junio C Hamano.
|
|
|
|
|
2005-09-13 04:39:15 +02:00
|
|
|
|
|
|
|
Documentation
|
|
|
|
--------------
|
|
|
|
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
|
|
|
|
|
|
|
|
GIT
|
|
|
|
---
|
2005-09-19 12:10:51 +02:00
|
|
|
Part of the gitlink:git[7] suite
|
2005-09-13 04:39:15 +02:00
|
|
|
|