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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:27:07  来源:igfitidea点击:

Searching code in a specific GitHub branch

gitgithub

提问by gCoder12

I am trying to search some code in a branch in a GitHub repository.

我正在尝试在 GitHub 存储库的分支中搜索一些代码。

However thisindicates that I can only search the default branch.

但是,表明我只能搜索默认分支。

Is there anyway I can search code in non-default branch in my GitHub repository?

无论如何,我可以在我的 GitHub 存储库的非默认分支中搜索代码吗?

采纳答案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 -Sfor 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_branchshould be available locally
  • git grepcan 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.

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

https://github.com/angular/angular/find/6.1.x

https://github.com/angular/angular/find/6.1.x