亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
characters

命名

git-grep  - 打印符合模式的行

概要

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]           [-l | --files-with-matches] [-L | --files-without-match]           [(-O | --open-files-in-pager) [<pager>]]           [-z | --null]           [-c | --count] [--all-match] [-q | --quiet]           [--max-depth <depth>]           [--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>…]

描述

在工作樹(shù)中跟蹤文件中查找指定的模式,在索引文件中注冊(cè)的斑點(diǎn)或給定樹(shù)對(duì)象中的斑點(diǎn)。模式是由換行符分隔的一個(gè)或多個(gè)搜索表達(dá)式的列表。作為搜索表達(dá)式的空字符串與所有行匹配。

組態(tài)

grep.lineNumber

如果設(shè)置為 true ,則-n默認(rèn)啟用選項(xiàng)。

grep.patternType

設(shè)置默認(rèn)的匹配行為。使用值basic,extendedfixed,或perl將啟用--basic-regexp,--extended-regexp--fixed-strings,或--perl-regexp相應(yīng)的選項(xiàng),而值default將返回到默認(rèn)匹配行為。

grep.extendedRegexp

如果設(shè)置為 true,則--extended-regexp默認(rèn)啟用選項(xiàng)。當(dāng)該grep.patternType選項(xiàng)設(shè)置為非時(shí),該選項(xiàng)將被忽略default。

grep.threads

要使用的 grep 工作線(xiàn)程數(shù)。如果未設(shè)置(或設(shè)置為0),則默認(rèn)使用8個(gè)線(xiàn)程(現(xiàn)在)。

grep.fullName

如果設(shè)置為 true ,則--full-name默認(rèn)啟用選項(xiàng)。

grep.fallbackToNoIndex

如果設(shè)置為 true ,則回退到 git grep --no-index,如果 git grep 在 git 存儲(chǔ)庫(kù)之外執(zhí)行。默認(rèn)為 false 。

選項(xiàng)

--cached

搜索工作樹(shù)中的追蹤文件,而不是搜索索引文件中注冊(cè)的斑點(diǎn)。

--no-index

搜索當(dāng)前目錄中不受 Git 管理的文件。

--untracked

除了在工作樹(shù)中跟蹤文件中搜索外,還可以在未跟蹤文件中搜索。

--no-exclude-standard

通過(guò)不尊重.gitignore機(jī)制來(lái)搜索被忽略的文件。只用于--untracked。

--exclude-standard

不要關(guān)注通過(guò).gitignore機(jī)制指定的忽略文件。僅在使用當(dāng)前目錄搜索文件時(shí)有用--no-index。

--recurse-submodules

遞歸搜索已在存儲(chǔ)庫(kù)中初始化并檢出的每個(gè)子模塊。當(dāng)與 <tree> 選項(xiàng)結(jié)合使用時(shí),所有子模塊輸出的前綴將是父項(xiàng)目的 <tree> 對(duì)象的名稱(chēng)。

--parent-basename <basename>

僅限內(nèi)部使用。為了使用 --recurse-submodules 選項(xiàng)產(chǎn)生統(tǒng)一的輸出,可以使用此選項(xiàng)將父級(jí)的 <tree> 對(duì)象的基名稱(chēng)提供給子模塊,以便子模塊可以將其輸出與父級(jí)名稱(chēng)相加,而不是使用 SHA1 子模塊。

-a   --text

像處理文本一樣處理二進(jìn)制文件。

--textconv

尊重 textconv 過(guò)濾器設(shè)置。

--no-textconv

不要兌現(xiàn) textconv 過(guò)濾器設(shè)置。這是默認(rèn)設(shè)置。

-i   --ignore-case

忽略模式和文件之間的大小寫(xiě)區(qū)別。

-I

不匹配二進(jìn)制文件中的模式。

--max-depth <depth>

對(duì)于命令行中給出的每個(gè) <pathspec> ,最多下降 <depth> 級(jí)別的目錄。負(fù)值意味著沒(méi)有限制。如果 <pathspec> 包含活動(dòng)通配符,則忽略此選項(xiàng)。換句話(huà)說(shuō),如果 “a *” 匹配名為 “a *” 的目錄,則“*”的字面匹配如此 -  max-depth 仍然有效。

-w   --word-regexp

僅在字邊界處匹配模式(或者從一行的開(kāi)始處開(kāi)始,或者以非單詞字符開(kāi)頭;結(jié)束于一行的末尾或后面跟著一個(gè)非單詞字符)。

-v   --invert-match

選擇不匹配的行。

-h   -H

默認(rèn)情況下,該命令顯示每個(gè)匹配的文件名。-h選項(xiàng)用于抑制此輸出。-H是否有完整性,除了-h在命令行中早先給出的覆蓋之外,不會(huì)執(zhí)行任何操作。

--full-name

從子目錄運(yùn)行時(shí),該命令通常會(huì)輸出相對(duì)于當(dāng)前目錄的路徑。該選項(xiàng)強(qiáng)制相對(duì)于項(xiàng)目頂部目錄輸出路徑。

-E   --extended-regexp   -G   --basic-regexp

對(duì)于模式使用 POSIX 擴(kuò)展/基本正則表達(dá)式。默認(rèn)是使用基本的正則表達(dá)式。

-P   --perl-regexp

為模式使用 Perl 兼容的正則表達(dá)式。

對(duì)這些類(lèi)型的正則表達(dá)式的支持是可選的編譯時(shí)間依賴(lài)性。如果 Git 沒(méi)有編譯支持它們,提供這個(gè)選項(xiàng)會(huì)導(dǎo)致它失效。

-F   --fixed-strings

使用固定字符串模式(不要將模式解釋為正則表達(dá)式)。

-n   --line-number

在行號(hào)前加上匹配的行。

-l   --files-with-matches   --name-only   -L   --files-without-match

不顯示每條匹配的行,只顯示包含(或不包含)匹配的文件的名稱(chēng)。為了更好的兼容性git diff--name-only是一個(gè)同義詞--files-with-matches。

-O<pager>   --open-files-in-pager=<pager>

打開(kāi)尋呼機(jī)中的匹配文件(不是輸出grep)。如果尋呼機(jī)恰好是 “較少” 或 “vi” ,并且用戶(hù)只指定一個(gè)模式,則第一個(gè)文件將自動(dòng)定位在第一個(gè)匹配位置。該pager論點(diǎn)是可選的; 如果指定,它必須粘貼到選項(xiàng)沒(méi)有空格。如果pager未指定,將使用默認(rèn)尋呼機(jī)(請(qǐng)參閱core.pager git-config [1] )。

-z   --null

輸出 \ 0 而不是通常跟在文件名后的字符。

-c   --count

顯示匹配的行數(shù),而不是顯示每條匹配的行。

--color=<when>

顯示結(jié)果為彩色。該值必須 always(默認(rèn)),never 或 auto 。

--no-color

關(guān)閉匹配突出顯示,即使配置文件將默認(rèn)設(shè)置為彩色輸出。和--color=never一樣。

--break

在不同文件的匹配之間打印空行。

--heading

在文件的上方顯示文件名,而不是在每個(gè)顯示的行的開(kāi)頭。

-p   --show-function

顯示包含匹配函數(shù)名稱(chēng)的上一行,除非匹配行是函數(shù)名稱(chēng)本身。該名稱(chēng)的確定方式與git diff制作補(bǔ)丁大小標(biāo)頭的方式相同(請(qǐng)參閱Defining a custom hunk-header gitattributes [5])。

-<num>   -C <num>   --context <num>

顯示 <num> 前導(dǎo)和尾部線(xiàn)條,并放置包含--連續(xù)的匹配組之間的線(xiàn)條。

-A <num>   --after-context <num>

顯示 <num> 尾隨線(xiàn),并--在連續(xù)的匹配組之間放置一行。

-B <num>   --before-context <num>

顯示 <num> 引出線(xiàn),并--在相鄰的匹配組之間放置一行。

-W   --function-context

顯示前一行中包含函數(shù)名稱(chēng)的周?chē)谋?,直到下一個(gè)函數(shù)名稱(chēng)之前的文本,從而有效地顯示找到匹配的整個(gè)函數(shù)。

--threads <num>

要使用的 grep 工作線(xiàn)程數(shù)。參見(jiàn)grep.threadsCONFIGURATION獲取更多信息。

-f <file>

從 <file> 中讀取模式,每行一個(gè)。

-e

下一個(gè)參數(shù)是模式。這個(gè)選項(xiàng)必須用于模式的開(kāi)頭,-并且應(yīng)該在將用戶(hù)輸入傳遞給 grep 的腳本中使用。多個(gè)模式組合在一起or。

--and   --or   --not   ( … )

指定如何使用布爾表達(dá)式組合多個(gè)模式。--or是默認(rèn)的運(yùn)營(yíng)商。--and--or優(yōu)先。-e必須用于所有模式。

--all-match

將多個(gè)模式表達(dá)式結(jié)合使用時(shí)--or,會(huì)指定此標(biāo)志以將匹配限制為具有與其匹配的所有行的文件。

-q   --quiet

不要輸出匹配的行; 取而代之的是,當(dāng)狀態(tài)0出現(xiàn)匹配時(shí)退出,當(dāng)不存在時(shí)退出非零狀態(tài)。

<tree>…

而不是在工作樹(shù)中搜索跟蹤文件,搜索給定樹(shù)中的斑點(diǎn)。

--

表示選項(xiàng)結(jié)束; 其余的參數(shù)是 <pathspec> 限制器。

<pathspec>…

如果給定,則將搜索限制為至少匹配一個(gè)模式的路徑。兩個(gè)前導(dǎo)路徑匹配并支持 glob(7)模式。

有關(guān) <pathspec> 語(yǔ)法的更多詳細(xì)信息,請(qǐng)參閱pathspec gitglossary [7]中的條目。

例子

git grep 'time_t' -- '*.[ch]'

查找time_t在所有跟蹤的 .c 和 .h 文件在工作目錄及其子目錄。

git grep -e '#define' --and \( -e MAX_PATH -e PATH_MAX \)

查找具有#define的線(xiàn),要么是MAX_PATHPATH_MAX。

git grep --all-match -e NODE -e Unexpected

查找具有NODEUnexpected兩者匹配的行的文件。

git grep solution -- :^Documentation

尋找solution,不包括Documentation中的文件。

Previous article: Next article: