2023-2025+: https://github.com/search?type=Code

Example inside a project: https://github.com/search?q=repo%3Agit%2Fgit+rebase&type=code

Update May 2023:

The new code search and code view is now generally available (May. 2023)

(As noted by holydragon in the comments, that does require to sign in to GitHub first)

At GitHub Universe last year, we announced a total redesign of GitHub's code search and navigation experience, powered by our all-new code search engine that we built from scratch.
And in February, we announced our public beta.

Today, we are rolling out this feature to all GitHub users.

Check out our blog post to learn more about how GitHub's new code search and code view can help you search, navigate, and understand your code.
And if you have feedback, please share it with us in our feedback discussion.


Update Dec. 2021: search has been improved again, with Search for an exact string, with support for substring matches and special characters, or regexps.

But only on cs.github.com, and still in beta (waitlist applies)


Update January 2013: a brand new search has arrived!, based on elasticsearch.org:

A search for stat within the ruby repo will be expressed as stat repo:ruby/ruby, and will now just workTM.
(the repo name is not case sensitive: test repo:wordpress/wordpress returns the same as test repo:Wordpress/Wordpress)

Will give:

And you have many other examples of search, based on followers, or on forks, or...


Update July 2012 (old days of Lucene search and poor code indexing, combined with broken GUI, kept here for archive):

The search (based on SolrQuerySyntax) is now more permissive and the dreaded "Invalid search query. Try quoting it." is gone when using the default search selector "Everything":)

(I suppose we can all than Tim Pease, which had in one of his objectives "hacking on improved search experiences for all GitHub properties", and I did mention this Stack Overflow question at the time ;) )

Here is an illustration of a grep within the ruby code: it will looks for repos and users, but also for what I wanted to search in the first place: the code!


Initial answer and illustration of the former issue (Sept. 2012 => March 2012)

You can use the advanced search GitHub form:

  • Choose Code, Repositories or Users from the drop-down and
  • use the corresponding prefixes listed for that search type.

For instance, Use the repo:username/repo-name directive to limit the search to a code repository.
The initial "Advanced Search" page includes the section:

Code Search:

The Code search will look through all of the code publicly hosted on GitHub. You can also filter by :

  • the language language:
  • the repository name (including the username) repo:
  • the file path path:

So if you select the "Code" search selector, then your query grepping for a text within a repo will work:


What is incredibly unhelpful from GitHub is that:

  • if you forget to put the right search selector (here "Code"), you will get an error message:
    "Invalid search query. Try quoting it."

  • the error message doesn't help you at all.
    No amount of "quoting it" will get you out of this error.

  • once you get that error message, you don't get the sections reminding you of the right association between the search selectors ("Repositories", "Users" or "Language") and the (right) search filters (here "repo:").
    Any further attempt you do won't display those associations (selectors-filters) back. Only the error message you see above...
    The only way to get back those arrays is by clicking the "Advance Search" icon:

  • the "Everything" search selector, which is the default, is actually the wrong one for all of the search filters! Except "language:"...
    (You could imagine/assume that "Everything" would help you to pick whatever search selector actually works with the search filter "repo:", but nope. That would be too easy)

  • you cannot specify the search selector you want through the "Advance Search" field alone!
    (but you can for "language:", even though "Search Language" is another combo box just below the "Search for" 'type' one...)


So, the user's experience usually is as follows:

  • you click "Advanced Search", glance over those sections of filters, and notice one you want to use: "repo:"
  • you make a first advanced search "repo:jruby/jruby stat", but with the default Search selector "Everything"
    => FAIL! (and the arrays displaying the association "Selectors-Filters" is gone)
  • you notice that "Search for" selector thingy, select the first choice "Repositories" ("Dah! I want to search within repositories...")
    => FAIL!
  • dejected, you select the next choice of selectors (here, "Users"), without even looking at said selector, just to give it one more try...
    => FAIL!
  • "Screw this, GitHub search is broken! I'm outta here!"
    ...
    (GitHub advanced search is actually not broken. Only their GUI is...)

So, to recap, if you want to "grep for something inside a Github project's code", as the OP Ben Humphreys, don't forget to select the "Code" search selector...

Answer from VonC on Stack Overflow
Top answer
1 of 12
326

2023-2025+: https://github.com/search?type=Code

Example inside a project: https://github.com/search?q=repo%3Agit%2Fgit+rebase&type=code

Update May 2023:

The new code search and code view is now generally available (May. 2023)

(As noted by holydragon in the comments, that does require to sign in to GitHub first)

At GitHub Universe last year, we announced a total redesign of GitHub's code search and navigation experience, powered by our all-new code search engine that we built from scratch.
And in February, we announced our public beta.

Today, we are rolling out this feature to all GitHub users.

Check out our blog post to learn more about how GitHub's new code search and code view can help you search, navigate, and understand your code.
And if you have feedback, please share it with us in our feedback discussion.


Update Dec. 2021: search has been improved again, with Search for an exact string, with support for substring matches and special characters, or regexps.

But only on cs.github.com, and still in beta (waitlist applies)


Update January 2013: a brand new search has arrived!, based on elasticsearch.org:

A search for stat within the ruby repo will be expressed as stat repo:ruby/ruby, and will now just workTM.
(the repo name is not case sensitive: test repo:wordpress/wordpress returns the same as test repo:Wordpress/Wordpress)

Will give:

And you have many other examples of search, based on followers, or on forks, or...


Update July 2012 (old days of Lucene search and poor code indexing, combined with broken GUI, kept here for archive):

The search (based on SolrQuerySyntax) is now more permissive and the dreaded "Invalid search query. Try quoting it." is gone when using the default search selector "Everything":)

(I suppose we can all than Tim Pease, which had in one of his objectives "hacking on improved search experiences for all GitHub properties", and I did mention this Stack Overflow question at the time ;) )

Here is an illustration of a grep within the ruby code: it will looks for repos and users, but also for what I wanted to search in the first place: the code!


Initial answer and illustration of the former issue (Sept. 2012 => March 2012)

You can use the advanced search GitHub form:

  • Choose Code, Repositories or Users from the drop-down and
  • use the corresponding prefixes listed for that search type.

For instance, Use the repo:username/repo-name directive to limit the search to a code repository.
The initial "Advanced Search" page includes the section:

Code Search:

The Code search will look through all of the code publicly hosted on GitHub. You can also filter by :

  • the language language:
  • the repository name (including the username) repo:
  • the file path path:

So if you select the "Code" search selector, then your query grepping for a text within a repo will work:


What is incredibly unhelpful from GitHub is that:

  • if you forget to put the right search selector (here "Code"), you will get an error message:
    "Invalid search query. Try quoting it."

  • the error message doesn't help you at all.
    No amount of "quoting it" will get you out of this error.

  • once you get that error message, you don't get the sections reminding you of the right association between the search selectors ("Repositories", "Users" or "Language") and the (right) search filters (here "repo:").
    Any further attempt you do won't display those associations (selectors-filters) back. Only the error message you see above...
    The only way to get back those arrays is by clicking the "Advance Search" icon:

  • the "Everything" search selector, which is the default, is actually the wrong one for all of the search filters! Except "language:"...
    (You could imagine/assume that "Everything" would help you to pick whatever search selector actually works with the search filter "repo:", but nope. That would be too easy)

  • you cannot specify the search selector you want through the "Advance Search" field alone!
    (but you can for "language:", even though "Search Language" is another combo box just below the "Search for" 'type' one...)


So, the user's experience usually is as follows:

  • you click "Advanced Search", glance over those sections of filters, and notice one you want to use: "repo:"
  • you make a first advanced search "repo:jruby/jruby stat", but with the default Search selector "Everything"
    => FAIL! (and the arrays displaying the association "Selectors-Filters" is gone)
  • you notice that "Search for" selector thingy, select the first choice "Repositories" ("Dah! I want to search within repositories...")
    => FAIL!
  • dejected, you select the next choice of selectors (here, "Users"), without even looking at said selector, just to give it one more try...
    => FAIL!
  • "Screw this, GitHub search is broken! I'm outta here!"
    ...
    (GitHub advanced search is actually not broken. Only their GUI is...)

So, to recap, if you want to "grep for something inside a Github project's code", as the OP Ben Humphreys, don't forget to select the "Code" search selector...

2 of 12
89

To seach within a repository, add the URL parametes /search?q=search_terms at the root of the repo, for example:

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

In the above example, it returns 2 results in Code and 160 results in Issues.

Discussions

How to search things in github repository?
You can press . in any GitHub repository to open it in an online version of VSCode. That should make searching in your project very easy. More on reddit.com
🌐 r/github
8
14
December 27, 2021
Reddit - The heart of the internet
Reddit is where millions of people gather for conversations about the things they care about, in over 100,000 subreddit communities. More on reddit.com
🌐 reddit.com
2 weeks ago
Get the Version Number of Program in Repo?
For your edit, you can curl the raw file served by github (note 'raw' next to 'history' and 'blame' at the top right corner of the file in your link). Curl it into grep and you've got yourself a real snappy tool. Note also that github is not git; git is the revision control system and github is a project management service that hosts git repositories and provides a bug tracker (among other features). It's like the difference between a video and youtube – the git repository exists without github, but github provides a means to share it. note that folks probably won't see a question asked in an edit – it's not like the thread gets bumped. also, you should look at asking these questions on SO. More on reddit.com
🌐 r/github
21
0
November 7, 2018
How to see my comments in github

Did you type "commenter:rifaterdemsahin" in the search bar? And if so, and didn't find what you're looking for, what was missing? (You can sort by Newest, etc.)

Here's some docs on how to search by various criteria: https://help.github.com/articles/searching-issues-and-pull-requests/

More on reddit.com
🌐 r/github
2
2
August 24, 2018
🌐
freeCodeCamp
freecodecamp.org › news › github-search-tips
GitHub Search Tips – How to Search Issues, Repos, and More Effectively on GitHub
October 17, 2022 - Another cool way to search through GitHub is by language. This helps you filter out repositories to a specific language. ... Using language:LANGUAGE. For example if you want to find repositories written in PHP, your search will be: language:PHP
🌐
GitHub
docs.github.com › en › issues › tracking-your-work-with-issues › using-issues › filtering-and-searching-issues-and-pull-requests
Filtering and searching issues and pull requests - GitHub Docs
You can find the search bar on each repository's Issues and Pull requests tabs and on your Issues and Pull requests dashboards. ... You can focus your cursor on the search bar above the issue or pull request list with a keyboard shortcut.
🌐
GitHub
github.com › search
Search · GitHub
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.
🌐
GitHub
github.blog › home › news & insights › the library › repository search on all repositories
Repository Search on all Repositories - The GitHub Blog
December 6, 2019 - To search globally, all you need to do is select the All repositories option: You may have already noticed that the command bar will also give you these options: Finally, if you didn’t find what you were looking for in your repository, you can turn a repository search into a global search by clicking Search all of GitHub.
🌐
GetGuru
getguru.com › reference › github-repository-search
GitHub Repository Search: How It Works, Common Issues, and Smarter Solutions
March 31, 2025 - The search functionality in GitHub repositories is designed to help users quickly locate code, issues, and documentation, but it does come with its quirks. First and foremost, GitHub employs indexing to facilitate fast search results. This means that as you upload code or make changes, GitHub continuously indexes your repository, making it available for search almost immediately.
Find elsewhere
🌐
GitHub
docs.github.com › en › search-github › searching-on-github
Searching on GitHub - GitHub Docs
You can use qualifiers to narrow your search and focus on specific categories of information. Finding files on GitHub · Searching for repositories · Searching topics · Searching code (legacy) Searching commits · Searching issues and pull requests · Searching discussions ·
🌐
GitHub
docs.github.com › en › repositories › working-with-files › using-files › navigating-code-on-github
Navigating code on GitHub - GitHub Docs
Symbol search is a feature of code search. For more information, see Understanding GitHub Code Search syntax. Select a repository, then navigate to a file containing symbols.
🌐
Grep
grep.app
Code Search | Grep by Vercel
Effortlessly search for code, files, and paths across a million GitHub repositories.
🌐
GitHub
docs.github.com › en › search-github › searching-on-github › searching-for-repositories
Searching for repositories - GitHub Docs
August 26, 2020 - Besides using in:readme, it's not possible to find repositories by searching for specific content within the repository. To search for a specific file or content within a repository, you can use the file finder or code-specific search qualifiers.
🌐
GitHub
github.com › orgs › community › discussions › 60088
Search within code of repositories · community · Discussion #60088
It's currently not possible to search within the code of a repository on mobile (at least iOS). If you want to pull up some random function in a large repo while away from your computer and don't know where it is, you have to open up GitHub in a web browser to search.
🌐
Wordpress
nataliekarolak.wordpress.com › 2025 › 07 › 01 › search-code-on-github-in-the-browser
Search code on GitHub in the browser – The BC Docs Librarian
July 2, 2025 - Either immediately type /, or click into the search box at the top of the page. Enter a search expression. The full-sized search box is displayed as , whereas your phone might shrink it to the magnifying glass only.
🌐
Medium
annaikoki.medium.com › how-to-find-a-file-in-a-github-repo-5920a8827c81
How to find a file in a GitHub Repo - Anna Ikoki - Medium
September 28, 2023 - To search in all of the organization’s repositories can be done by entering this in the search box: org:organization-user-name filename:specific-file-name · To search the whole of Github: filename:the-file-name
🌐
GitHub
docs.github.com › en › search-github › getting-started-with-searching-on-github › about-searching-on-github
About searching on GitHub - GitHub Docs
March 15, 2022 - You can search globally across ... across all of GitHub, type what you're looking for into the search field at the top of any page, and choose "Search all of GitHub" in the search dropdown menu....
🌐
GitHub
cli.github.com › manual › gh_search_repos
GitHub CLI | Take GitHub to the command line
# Search repositories matching set of keywords "cli" and "shell" $ gh search repos cli shell # Search repositories matching phrase "vim plugin" $ gh search repos "vim plugin" # Search repositories using raw search qualifiers as separate arguments ...
🌐
GitHub
github.com › features › code-search
GitHub Code Search · GitHub
Dig deeper into complex codebases with tightly integrated search, code navigation and browsing. ... Code search makes it effortless to quickly find what I'm looking for in my code, or across all of GitHub
🌐
GitHub
docs.github.com › en › search-github › searching-on-github › searching-code
Searching code (legacy) - GitHub Docs
August 24, 2021 - Only the default branch is indexed for code search. Only files smaller than 384 KB are searchable. Up to 4,000 private repositories are searchable.
🌐
GitHub
docs.github.com › en › get-started › start-your-journey › finding-inspiration-on-github
Finding inspiration on GitHub - GitHub Docs
Click Star next to repositories and topics that interest you, so you can easily find them again later. Navigate to your stars page to see all your starred repositories and topics. Navigate to https://github.com/search.
🌐
GitHub
github.com › github › docs › blob › main › content › search-github › getting-started-with-searching-on-github › about-searching-on-github.md
docs/content/search-github/getting-started-with-searching-on-github/about-searching-on-github.md at main · github/docs
To search within a particular repository or organization, navigate to the repository or organization page, type what you're looking for into the search field at the top of the page, and press Enter.
Author   github