grep
NAME名
git-grep - Print lines matching a patterngit-grep - パターンと一致する行を印刷する
SYNOPSIS概要
git grep [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp] [-v | --invert-match] [-h|-H] [--full-name] [-E | --extended-regexp] [-G | --basic-regexp] [-P | --perl-regexp] [-F | --fixed-strings] [-n | --line-number] [--column] [-l | --files-with-matches] [-L | --files-without-match] [(-O | --open-files-in-pager) [<pager>]] [-z | --null] [ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet] [--max-depth <depth>] [--[no-]recursive] [--color[=<when>] | --no-color] [--break] [--heading] [-p | --show-function] [-A <post-context>] [-B <pre-context>] [-C <context>] [-W | --function-context] [--threads <num>] [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>…] [--recurse-submodules] [--parent-basename <basename>] [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>…] [--] [<pathspec>…]
DESCRIPTION説明
Look for specified patterns in the tracked files in the work tree, blobs registered in the index file, or blobs in given tree objects. Patterns are lists of one or more search expressions separated by newline characters. An empty string as search expression matches all lines.作業ツリー内の追跡対象ファイル、インデックスファイルに登録されているBLOB、または指定されたツリーオブジェクト内のBLOBで、指定されたパターンを探します。パターンは、改行文字で区切られた1つ以上の検索式のリストです。検索式としての空の文字列はすべての行に一致します。
CONFIGURATION設定
- grep.lineNumber
-
If set to true, enable
-n
option by default.trueに設定されている場合、-n
デフォルトでオプションを有効にします。 - grep.column
-
If set to true, enable the
--column
option by default.trueに設定した場合、--column
デフォルトでこのオプションを有効にします。 - grep.patternType
-
Set the default matching behavior. Using a value of basic, extended, fixed, or perl will enable the
--basic-regexp
,--extended-regexp
,--fixed-strings
, or--perl-regexp
option accordingly, while the value default will return to the default matching behavior.デフォルトの一致動作を設定します。値を用いて、基本的な、拡張、固定、またはPerlのは有効になり--basic-regexp
、--extended-regexp
、--fixed-strings
、または--perl-regexp
値が、それに応じてオプションのデフォルトは、デフォルトのマッチング動作に戻ります。 - grep.extendedRegexp
-
If set to true, enable
--extended-regexp
option by default. This option is ignored when thegrep.patternType
option is set to a value other than default.trueに設定されている場合、--extended-regexp
デフォルトでオプションを有効にします。このオプションがdefaultgrep.patternType
以外の値に設定されている場合、このオプションは無視されます。 - grep.threads
-
Number of grep worker threads to use. If unset (or set to 0), 8 threads are used by default (for now).使用するgrepワーカースレッドの数 設定されていない(または0に設定されている)場合、デフォルトでは8スレッドが使用されます(現時点では)。
- grep.fullName
-
If set to true, enable
--full-name
option by default.trueに設定されている場合、--full-name
デフォルトでオプションを有効にします。 - grep.fallbackToNoIndex
-
If set to true, fall back to git grep --no-index if git grep is executed outside of a git repository. Defaults to false.trueに設定した場合、git grepがgitリポジトリ外で実行された場合はgit grep --no-indexにフォールバックします。デフォルトはfalseです。
OPTIONSオプション
- --cached - キャッシュ
-
Instead of searching tracked files in the working tree, search blobs registered in the index file.作業ツリーで追跡ファイルを検索する代わりに、インデックスファイルに登録されているBLOBを検索します。
- --no-index
-
Search files in the current directory that is not managed by Git.Gitによって管理されていない現在のディレクトリ内のファイルを検索します。
- --untracked - 未追跡
-
In addition to searching in the tracked files in the working tree, search also in untracked files.作業ツリー内の追跡ファイルを検索するだけでなく、追跡されていないファイルも検索します。
- --no-exclude-standard
-
Also search in ignored files by not honoring the
.gitignore
mechanism. Only useful with--untracked
..gitignore
メカニズムを尊重しないことで、無視されたファイルも検索します。とだけ役立つ--untracked
。 - --exclude-standard
-
Do not pay attention to ignored files specified via the
.gitignore
mechanism. Only useful when searching files in the current directory with--no-index
..gitignore
メカニズムによって指定された無視されたファイルに注意を払わないでください。現在のディレクトリ内のファイルを検索するときにのみ役立ちます--no-index
。 - --recurse-submodules
-
Recursively search in each submodule that has been initialized and checked out in the repository. When used in combination with the <tree> option the prefix of all submodule output will be the name of the parent project’s <tree> object.リポジトリ内で初期化およびチェックアウトされた各サブモジュールを再帰的に検索します。<tree>オプションと組み合わせて使用??すると、すべてのサブモジュール出力の接頭辞は、親プロジェクトの<tree>オブジェクトの名前になります。
- -a
- --text - テキスト
-
Process binary files as if they were text.バイナリファイルをテキストのように処理します。
- --textconv
-
Honor textconv filter settings.textconvフィルタ設定を尊重します。
- --no-textconv
-
Do not honor textconv filter settings. This is the default.textconvフィルタ設定を尊重しません。これがデフォルトです。
- -i -私
- --ignore-case
-
Ignore case differences between the patterns and the files.パターンとファイルの大文字と小文字の違いを無視します。
- -I -私
-
Don’t match the pattern in binary files.バイナリファイルのパターンと一致させないでください。
- --max-depth <depth> --max-depth <深さ>
-
For each <pathspec> given on command line, descend at most <depth> levels of directories. A value of -1 means no limit. This option is ignored if <pathspec> contains active wildcards. In other words if "a*" matches a directory named "a*", "*" is matched literally so --max-depth is still effective.コマンドラインで指定された各<pathspec>について、最大<depth>レベルのディレクトリまで降ります。値-1は無制限を意味します。<pathspec>にアクティブなワイルドカードが含まれている場合、このオプションは無視されます。言い換えれば、 "a *"が "a *"という名前のディレクトリに一致する場合、 "*"は文字通りに一致するので、 - max-depthは依然として有効です。
- -r
- --recursive - 再帰的
-
Same as
--max-depth=-1
; this is the default.と同じ--max-depth=-1
です。これがデフォルトです。 - --no-recursive
-
Same as
--max-depth=0
.と同じ--max-depth=0
です。 - -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.一致しない行を選択してください。
- -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.デフォルトでは、このコマンドは各一致のファイル名を表示します。-h
optionを使用してこの出力を抑制します。-H
完全を期すためのもの-h
であり、コマンドラインで前に指定したものを上書きする以外は何もしません。 - --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.サブディレクトリから実行すると、コマンドは通常、現在のディレクトリからの相対パスを出力します。このオプションを選択すると、パスはプロジェクトのトップディレクトリからの相対パスで出力されます。
- -E
- --extended-regexp
- -G
- --basic-regexp
-
Use POSIX extended/basic regexp for patterns. Default is to use basic regexp.パターンにはPOSIX拡張/基本正規表現を使用してください。デフォルトは基本的な正規表現を使うことです。
- -P
- --perl-regexp
-
Use Perl-compatible regular expressions for patterns.パターンにはPerl互換の正規表現を使用してください。
Support for these types of regular expressions is an optional compile-time dependency. If Git wasn’t compiled with support for them providing this option will cause it to die.これらの種類の正規表現のサポートは、オプションのコンパイル時の依存関係です。Gitがそれらをサポートするようにコンパイルされていない場合、このオプションを提供することでそれは死にます。
- -F
- --fixed-strings - 固定文字列
-
Use fixed strings for patterns (don’t interpret pattern as a regex).パターンに固定文字列を使用します(patternを正規表現として解釈しないでください)。
- -n
- --line-number - 行番号
-
Prefix the line number to matching lines.一致する行の先頭に行番号を付けます。
- --column - カラム
-
Prefix the 1-indexed byte-offset of the first match from the start of the matching line.一致する行の先頭から最初の一致の1から始まるバイトオフセットを前に付けます。
- -l
- --files-with-matches
- --name-only
- -L
- --files-without-match
-
Instead of showing every matched line, show only the names of files that contain (or do not contain) matches. For better compatibility with git diff,
--name-only
is a synonym for--files-with-matches
.一致したすべての行を表示する代わりに、一致を含む(または含まない)ファイルの名前のみを表示します。とのより良い互換性のためのgit diffを、--name-only
同義語です--files-with-matches
。 - -O[<pager>] -O [<ページャ>]
- --open-files-in-pager[=<pager>] --open-files-in-pager [= <pager>]
-
Open the matching files in the pager (not the output of grep). If the pager happens to be "less" or "vi", and the user specified only one pattern, the first file is positioned at the first match automatically. The
pager
argument is optional; if specified, it must be stuck to the option without a space. Ifpager
is unspecified, the default pager will be used (seecore.pager
in git-config[1]).ページャーで一致するファイルを開きます(grepの出力ではありません)。ポケットベルが "less"または "vi"で、ユーザーがパターンを1つだけ指定した場合、最初のファイルは自動的に最初の一致位置に配??置されます。pager
引数はオプションです。指定した場合は、スペースなしでオプションに固定する必要があります。場合pager
、デフォルトのページャが使用される指定されていない(参照core.pager
中のgit-設定[1] )。 - -z
- --null - ヌル
-
Output %%BODY%% instead of the character that normally follows a file name.通常ファイル名の後に続く文字の代わりに\ 0を出力します。
- -o
- --only-matching
-
Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.一致する行の一致する(空でない)部分だけを別々の出力行に表示します。
- -c
- --count - カウント
-
Instead of showing every matched line, show the number of lines that match.一致した行をすべて表示する代わりに、一致した行の数を表示します。
- --color[=<when>] --color [= <when>]
-
Show colored matches. The value must be always (the default), never, or auto.色付きの試合を表示します。値はalways(デフォルト)、never、またはautoである必要があります。
- --no-color - 色なし
-
Turn off match highlighting, even when the configuration file gives the default to color output. Same as
--color=never
.設定ファイルでデフォルトのカラー出力が指定されている場合でも、一致強調表示をオフにします。と同じ--color=never
です。 - --break - ブレーク
-
Print an empty line between matches from different files.異なるファイルからの一致の間に空の行を印刷します。
- --heading - 見出し
-
Show the filename above the matches in that file instead of at the start of each shown line.表示されている各行の先頭ではなく、ファイル内の一致箇所の上にファイル名を表示します。
- -p
- --show-function
-
Show the preceding line that contains the function name of the match, unless the matching line is a function name itself. The name is determined in the same way as git diff works out patch hunk headers (see Defining a custom hunk-header in gitattributes[5]).一致する行が関数名そのものでない限り、一致の関数名を含む前の行を表示します。名前は、同じ方法で決定されたGitのdiffは(参照パッチ塊ヘッダを動作カスタム塊ヘッダの定義にgitattributes [5] )。
- -<num> - <番号>
- -C <num> -C <番号>
- --context <num>
-
Show <num> leading and trailing lines, and place a line containing
--
between contiguous groups of matches.<num>行の先頭と末尾の行を表示し--
、連続した一致グループの間を含む行を配置します。 - -A <num> -A <数値>
- --after-context <num>
-
Show <num> trailing lines, and place a line containing
--
between contiguous groups of matches.末尾に<num>行を表示し--
、連続する一致グループ間を含む行を配置します。 - -B <num> -B <番号>
- --before-context <num>
-
Show <num> leading lines, and place a line containing
--
between contiguous groups of matches.<num>行目を表示し--
、連続した一致グループ間を含む行を配置します。 - -W
- --function-context - 機能コンテキスト
-
Show the surrounding text from the previous line containing a function name up to the one before the next function name, effectively showing the whole function in which the match was found.関数名を含む前の行から次の関数名の前のテキストまでの周囲のテキストを表示し、一致が見つかった関数全体を効果的に表示します。
- --threads <num> --threads <番号>
-
Number of grep worker threads to use. See
grep.threads
in CONFIGURATION for more information.使用するgrepワーカースレッドの数 詳細についてgrep.threads
は設定を参照してください。 - -f <file> -f <ファイル>
-
Read patterns from <file>, one per line.<file>から1行に1つずつパターンを読み込みます。
- -e
-
The next parameter is the pattern. This option has to be used for patterns starting with
-
and should be used in scripts passing user input to grep. Multiple patterns are combined by or.次のパラメータはパターンです。このオプションは、で始まるパターン-
に使用する必要があり、ユーザー入力をgrepに渡すスクリプトで使用する必要があります。複数のパターンは、またはによって結合されます。 - --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.ブール式を使用して複数のパターンを組み合わせる方法を指定します。--or
デフォルトの演算子です。--and
より優先順位が高い--or
。-e
すべてのパターンに使用する必要があります。 - --all-match
-
When giving multiple pattern expressions combined with
--or
, this flag is specified to limit the match to files that have lines to match all of them.複数のパターン表現を組み合わせて--or
指定するとき、このフラグは、それらすべてに一致する行があるファイルに一致を制限するために指定されます。 - -q
- --quiet - 静か
-
Do not output matched lines; instead, exit with status 0 when there is a match and with non-zero status when there isn’t.一致した行を出力しません。代わりに、一致がある場合はステータス0で終了し、一致がない場合はゼロ以外のステータスで終了します。
- <tree>… <tree>…
-
Instead of searching tracked files in the working tree, search blobs in the given trees.作業ツリーで追跡されているファイルを検索する代わりに、与えられたツリーでブロブを検索します。
- -- -
-
Signals the end of options; the rest of the parameters are <pathspec> limiters.オプションの終わりを知らせます。残りのパラメータは<pathspec>リミッタです。
- <pathspec>… <pathspec>…
-
If given, limit the search to paths matching at least one pattern. Both leading paths match and glob(7) patterns are supported.指定されている場合、検索を少なくとも1つのパターンに一致するパスに制限します。両方の先行パスが一致し、glob(7)パターンがサポートされています。
For more details about the <pathspec> syntax, see the pathspec entry in gitglossary[7].<pathspec>構文の詳細については、gitglossary [7]のpathspecエントリを参照してください。
EXAMPLES例
-
git grep 'time_t' -- '*.[ch]'
-
Looks for
time_t
in all tracked .c and .h files in the working directory and its subdirectories.time_t
作業ディレクトリとそのサブディレクトリ内の追跡されたすべての.cファイルと.hファイルを探します。 -
git grep -e '#define' --and \( -e MAX_PATH -e PATH_MAX \)
-
Looks for a line that has
#define
and eitherMAX_PATH
orPATH_MAX
.またはの#define
いずれかを持つ行を探します。MAX_PATH
PATH_MAX
-
git grep --all-match -e NODE -e Unexpected
-
Looks for a line that has
NODE
orUnexpected
in files that have lines that match both.両方に一致する行があるNODE
かUnexpected
、ファイルにある行を探します。 -
git grep solution -- :^Documentation
-
Looks for
solution
, excluding files inDocumentation
.solution
内のファイルを除いて、を探しますDocumentation
。
GIT
Part of the git[1] suite一部のgit [1]スイート
関連記事
- write-tree
- verify-pack
- update-ref
- update-index
- symbolic-ref
- show-ref
- rev-parse
- rev-list
- read-tree
- merge-base
- ls-files
- hash-object
- for-each-ref
- diff-index
- count-objects
- commit-tree
- checkout-index
- check-ignore
- cat-file
- bundle
- archive
- instaweb
- filter-branch
- reflog
- fsck
- gc
- clean
- Workflows
- Tutorial
- Revisions
- gitmodules
- gitignore
- githooks
- Glossary
- Everyday Git
- gitattributes
- update-server-info
- daemon
- fast-import
- svn
- request-pull
- send-email
- format-patch
- am
- blame
- bisect
- revert
- rebase
- cherry-pick
- apply
- describe
- shortlog
- show
- submodule
- remote
- push
- pull
- fetch
- worktree
- tag
- stash
- log
- mergetool
- merge
- checkout
- branch
- mv
- rm
- reset
- commit
- diff
- status
- add
- clone
- init
- help
- config
- git
スポンサーリンク