有一种方法来grep的东西在一个Github项目的代码?

我可以拉源和grep它在本地,但我想知道它是否可能通过网络界面或第三方替代方案。

想法吗?


当前回答

最近的私有存储库有一个用于搜索该回购的搜索字段。

然而,令人困惑的是,公共存储库似乎无法使用此功能。

其他回答

在“搜索”框中使用搜索词和“in:”文件。

“搜索”将创建一个下拉框,询问您想要搜索的位置。

访问这里:https://github.com/search并输入“pattern repo:user_name/repo_name”。

例如,在fastai用户的fastai repo中搜索cnn_learner,输入如下:

cnn_learner回购:fastai / fastai

就是这样。唯一的烦恼是你需要额外的点击。它会告诉你:

我们找不到任何与“cnn_learner”匹配的存储库 回购:fastai / fastai '

因为默认情况下,它会搜索与搜索字符串匹配的存储库…

所以只要点击左边的“代码”,它就会显示你想要的东西。

或者直接使用如下URL获取代码搜索结果:

https://github.com/search?q=cnn_learner+repo%3Afastai%2Ffastai&type=code

只需使用SourceGraph.com,而不是在GitHub搜索,或安装它的扩展:

我搜索源代码内的Github仓库与免费Sourcegraph Chrome扩展

我浏览了SourceForge的Chrome扩展文档,并通过阅读一些Github的Codebase搜索文档来查看我使用Github的搜索引擎本身搜索目录名所需要的东西

更新

由于XHR问题和API更改,下面的bookmarklet黑客被破坏。

值得庆幸的是,Github现在有“一个全新的代码搜索”,它可以出色地完成这项工作。


Checkout this voodoo: Github code search userscript. Follow the directions there, or if you hate bloating your browser with scripts and extensions, use my bookmarkified bundle of the userscript: javascript:(function(){var s='https://raw.githubusercontent.com/skratchdot/github-enhancement-suite/master/build/github-enhancement-suite.user.js',t='text/javascript',d=document,n=navigator,e;(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)})();doIt('');void(''); Save the source above as the URL of a new bookmark. Browse to any Github repo, click the bookmark, and bam: in-page, ajaxified code search. CAVEAT Github must index a repo before you can search it. Abracadabra... Here's a sample search from the annotated ECMAScript 5.1 specification repository:

最近的私有存储库有一个用于搜索该回购的搜索字段。

然而,令人困惑的是,公共存储库似乎无法使用此功能。