search - 在 github.com 上搜索代码片段存储库

标签 search github full-text-search code-search

如何在 github.com 上搜索代码片段?当我在存储库中搜索 MSG_PREPARE 时,ErikZalm/Marlin github 显示 nothing

我正在使用 https://github.com/search 中描述的存储库代码搜索语法与

repo:ErikZalm/Marlin MSG_PREPARE

没有结果,但可以在此存储库中找到 MSG_PREPARE here 。我错过了什么吗? github.com上没有代码搜索吗?

最佳答案

在撰写此答案时,与提出此问题的时间(即大约 8 年前)相比,github 已经取得了很好的进展,尽管仍没有达到您所看到的长度。

GitHub 代码搜索受以下规则限制:https://docs.github.com/en/github/searching-for-information-on-github/searching-code 。引用相同内容:

Code in forks is only searchable if the fork has more stars than the parent repository.
Forks with fewer stars than the parent repository are not indexed for code search.
To include forks with more stars than their parent in the search results, you will need to add fork:true or fork:only to your query.
For more information, see "Searching in forks."

因此,我们可以使用 fork:true 选项在 fork 内进行搜索,尽管正如预期的那样,因为与父项相比,存储库 ErikZalm/Marlin 的星数较少MarlinFirmware/Marlin,fork 中的代码仍然没有索引。因此advance search shows no good except a match to the repo.

但是,如果您对父级执行相同的搜索,它将显示代码上的匹配项。 Here are the matches for MSG_PREPARE in the parent repo MarlinFirmware/Marlin

幸运的是,据我所知,SourceGraph 是从事该领域工作的一家公司:https://about.sourcegraph.com/

因此,您可以使用 SourceGraph 轻松搜索您想要的内容: Here are the matches for MSG_PREPARE in the ErikZalm/Marlin using SourceGraph Cloud

关于search - 在 github.com 上搜索代码片段存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13321936/

相关文章:

git - 通过 Github API 获取 token

git - git push 失败,无法加载 github.com

PHP 搜索查询不工作

ajax - Google 即搜即得如何运作?

git - Github 或任何其他基于云的存储库服务(Gitlab、Bitbucket)如何存储源代码文件和目录?

sql-server - 使用 CONTAINSTABLE 转义 SQL Server 全文搜索查询中的符号

mysql - 最快的 SQL 全文搜索

php - 从正则表达式得到错误 'nothing to repeat at offset 1'

search - 如何获得 Elasticsearch 以在尖括号内返回结果?

PHP mysql - ...和列 ='anything' ...?