git 在特定 GitHub 分支中搜索代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31891733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Searching code in a specific GitHub branch
提问by gCoder12
采纳答案by VonC
Not from the GitHub web interface itself, as mentioned in "How can I search for a commit message on GitHub?": only the default branch(generally master
) is indexed.
不是来自 GitHub Web 界面本身,如“如何在 GitHub 上搜索提交消息?”中所述:仅对默认分支(通常master
)编入索引。
Your best bet is to clone the repository, and there, search in all branches (with git log -S
for instance).
最好的办法是克隆存储库,然后在所有分支中搜索(git log -S
例如使用)。
回答by dhilt
Using console, I would search for specific code in a specific branch with the following
使用控制台,我将使用以下内容在特定分支中搜索特定代码
git grep 'my_search_text' my_branch
my_branch
should be available locallygit grep
can perform pattern matching of high complexity (see the documentation)
my_branch
应该在本地可用git grep
可以执行高复杂度的模式匹配(参见文档)
回答by Simon_Weaver
If you know the filenameyou can use Find File
.
如果您知道文件名,则可以使用Find File
.