如何在github上搜索以获得完全匹配的内容(例如引号对Google的影响) [英] How to search on github to get exact matches (like what quotes do for Google)
问题描述
我可以使用诸如"system <<-"
之类的引号来搜索Google的完全匹配项.如何为github做类似的事情?我无法使其正常工作.
I can search exact matches from google by using quotes like "system <<-"
. How to do the similar thing for github? I can't make it work.
推荐答案
您不能.官方GitHub 搜索规则:
You can't. The official GitHub searching rules:
由于搜索代码的复杂性,存在一些限制 有关如何执行搜索的信息:
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
- 仅考虑默认分支.在大多数情况下,这将是 master 分支.
- 仅可搜索小于 384 KB 的文件.
- 仅可搜索少于500,000个文件的存储库.
- 搜索源代码时,必须始终至少包含一个搜索词.例如,搜索
language:go
无效,而amazing language:go
无效. - 最多,搜索结果可以显示同一文件中的两个片段,但是文件中可能会有更多结果.
- 您不能在搜索查询中使用以下通配符:
. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]
搜索将仅忽略这些符号.
- Only the default branch is considered. In most cases, this will be the master branch.
- Only files smaller than 384 KB are searchable.
- Only repositories with fewer than 500,000 files are searchable.
- You must always include at least one search term when searching source code. For example, searching for
language:go
is not valid, whileamazing language:go
is. - At most, search results can show two fragments from the same file, but there may be more results within the file.
- You can't use the following wildcard characters as part of your search query:
. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]
The search will simply ignore these symbols.
克隆并使用git-grep
:
git 支持使用 git-grep 在源中进行搜索命令.只需克隆存储库并在文件夹中使用命令即可:
Clone and use git-grep
:
git support searching in sources with git-grep command. Just clone a repository and use the command in the folder:
git grep "text-to-search"
替代项:
我建议您尝试使用 ripgrep 工具,该工具既快速又简单.像git-grep
一样工作,但看起来更好:
I recommend you to try ripgrep tool, it's fast and simple. Works like git-grep
but looks nicer:
rg "text-to-search"
您可以使用标准的grep
搜索文件中的任何文本:
And you can use the standard grep
to search any text in files:
grep -r "text-to-search" /repository
这篇关于如何在github上搜索以获得完全匹配的内容(例如引号对Google的影响)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!