View code search results by repository

I often find myself needing to find the names of all repositories in my organization that contain a reference to a specific keyword (eg class name). Is there a way in the GitHub UI to view search results organized by repository?

If I do a “repository” search, it only searches for my keyword in the repository name or description. I need it to search the code. If I do a “code” search, it searches the code but returns too many pages of results, with the same repository listed multiple times. I then need to click through many pages of results to get the names of all the unique repos.

For example, if I’m searching for “HelloWorld” and I have these repositories:

RepositoryA : contains “HelloWorld” in the code 1 time

RepositoryB : does not contain “HelloWorld” anywhere in the code

RepositoryC : contains “HelloWorld” in the code 100 times

HelloWorld : contains “HelloWorld” in the code 2 times

I want to quickly get the list ( RepositoryA , RepositoryC , HelloWorld ) since these are the repos that contain code containing “HelloWorld”.

If I do a repository search, I would get only one result: HelloWorld.

If I do a code search, I would get 103 results from 3 repositories. I would then have to scroll through 11 pages of results just to figure out what those 3 repositories are. I need a quicker way to get those 3 repository names.


There isn’t a way to do what you want through the UI, but you could write a script that accesses the GitHub API to perform a code search and coalesce the results to extract only the information you want.

Hey! I’ve actually run into the exact same question, but I’m having trouble figuring out how to do this using the search API. Could you perhaps provide a demonstrative example of how to do this? My query in particular is to search for all repositories which use the “await” keyword in a JavaScript file. 


For that kind of thing, you don’t really need to use the API. You could use the standard search by extension to find code that uses await in a file with the .js extension.