不是在Git存储库中,而是在GitHub中——我如何搜索特定存储库/分支的提交消息?
当前回答
这已从GitHub删除。我使用:
$git log --all --oneline | grep "search query"
你也可以通过作者筛选:
$git log --all --oneline --author=rickhanlonii | grep "search query"
其他回答
你过去可以这样做,但GitHub在2013年年中的某个时候删除了这个功能。要在本地实现这一点,您可以这样做:
git log -g --grep=STRING
(如果您想搜索其他分支和悬空提交,请使用-g标志。)
-g, --walk-reflogs
Instead of walking the commit ancestry chain, walk reflog entries from
the most recent one to older ones.
从搜索代码的帮助页面来看,这似乎还不可能。
您可以在存储库中搜索文本,包括选择要搜索的文件或路径的能力,但不能指定要在提交中搜索。
也许可以向他们提出这个建议?
由于这已经从GitHub中删除,我一直在Linux上使用gitk来做这件事。
从终端转到存储库并键入gitk。
在GUI的中间,有一个搜索框。它提供了一个很好的过滤器:
范围包含,触摸路径,添加/删除字符串,改变行匹配
匹配类型—Exact/IgnCase/Regexp
搜索字段-所有字段/标题/评论/提交者
2023年1月更新:(八年后)
使用GitHub CLI gh v2.22.0(2023年1月),您可以从本地克隆的GitHub存储库中搜索:
参见gh search commit:
例子:
# search commits matching set of keywords "readme" and "typo"
$ gh search commits readme typo
# search commits matching phrase "bug fix"
$ gh search commits "bug fix"
# search commits committed by user "monalisa"
$ gh search commits --committer=monalisa
2017年1月更新(两年后):
您现在可以搜索提交消息!(仍然只在主分支中)
2015年2月:考虑到目前基于Elasticsearch(2013年1月引入)的搜索基础设施,不确定这是否可能实现。
作为“来自可信和/或官方来源”的答案,以下是对GitHub负责引入Elasticsearch的人员的采访(2013年8月)。
Tim Pease: We have two document types in there: One is a source code file and the other one is a repository. The way that git works is you have commits and you have a branch for each commit. Repository documents keep track of the most recent commit for that particular repository that has been indexed. When a user pushes a new commit up to Github, we then pull that repository document from elasticsearch. We then see the most recently indexed commit and then we get a list of all the files that had been modified, or added, or deleted between this recent push and what we have previously indexed. Then we can go ahead and just update those documents which have been changed. We don’t have to re-index the entire source code tree every time someone pushes. Andrew Cholakian: So, you guys only index, I’m assuming, the master branch. Tim Pease: Correct. It’s only the head of the master branch that you’re going to get in there and still that’s a lot of data, two billion documents, 30 terabytes. Andrew Cholakian: That is awesomely huge.
[...]
Tim Pease: With indexing source code on push, it’s a self-healing process. We have that repository document which keeps track of the last indexed commit. If we missed, just happen to miss three commits where those jobs fail, the next commit that comes in, we’re still looking at the diff between the previous commit that we indexed and the one that we’re seeing with this new push. You do a git diff and you get all the files that have been updated, deleted, or added. You can just say, “Okay, we need to remove these files. We need to add these files, and all that.” It’s self-healing and that’s the approach that we have taken with pretty much all of the architecture.
这意味着并非所有回购的所有分支都将使用该方法进行索引。 目前无法使用全局提交消息搜索。 Tim Pease本人也确认提交消息没有被索引。
注意,获得本地克隆的自己的elasticsearch本地索引并不是不可能的:参见“用elasticsearch搜索git存储库”
但对于特定的回购,最简单的方法仍然是克隆它,并执行以下操作:
git log --all --grep='my search'
(更多选项在“如何通过提交消息搜索Git存储库?”)
您可以对谷歌爬取的存储库执行此操作(结果因存储库而异)。
搜索所有爬取存储库的所有分支,查找“更改许可”
“变更许可证”网站:https://github.com/*/*/commits
搜索所有爬虫库的主分支“change license”:
“变更许可证”网站:https://github.com/*/*/commits/master
搜索所有爬过的twitter存储库的主分支“更改许可证”
“变更许可证”网站:https://github.com/twitter/*/commits/master
搜索twitter/some_project存储库的所有分支,查找“change license”
“变更许可证”网站:https://github.com/twitter/some_project/commits
推荐文章
- 在另一个目录中运行操作
- GitHub克隆与OAuth访问令牌
- 我可以在GitHub上对要点进行拉请求吗?
- Git:在推送后删除提交的文件
- 在GitHub中编辑git提交消息
- Github:导入上游分支到fork
- GitHub上的分叉和克隆有什么区别?
- 如何将现有的解决方案从Visual Studio 2013添加到GitHub
- 是否可以在GitHub上搜索特定的文件名?
- GitHub -未能连接到GitHub 443 windows/连接到GitHub失败-无错误
- 我怎么能让詹金斯CI与Git触发器推到主人?
- 如何从拉请求中删除提交
- 如何用分发文件发布npm包?
- 如何同步项目到GitHub与Android工作室?
- 跟踪在GitHub上创建的一个新的远程分支