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

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

想法吗?


当前回答

访问这里: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

其他回答

更新

由于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:

谷歌允许您在项目中搜索,但不包括代码:(

网站:https://github.com/CreateJS/EaselJS测试

只需访问该回购的主页,然后在左上方的搜索框中输入您的搜索词。

第一个建议的结果将被标记为“in this repository”。点击它,或者直接按回车键。

要在存储库中搜索,添加URL参数/搜索?Q =search_terms在repo的根目录,例如:

https://github.com/bmewburn/vscode-intelephense/search?q=phpstorm

在上面的例子中,它在Code中返回2个结果,在Issues中返回160个结果。

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

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