https://github.blog/2023-05-08-github-code-search-is-generally-available/ / Blog * Engineering * Product * Security * Open Source * Enterprise * Changelog * Community * Education * Company * Policy Free trial Contact sales Search by Keyword [ ] Search * Product GitHub code search is generally available The world's code is now at your fingertips. GitHub code search is generally available Author Colin MerkelColin Merkel May 8, 2023 * * * One of the most fundamental tasks developers perform is reading and understanding code. Whether planning and implementing a new feature, investigating a bug, or reviewing a pull request, developers typically spend more time reading and understanding code than writing it. That's why, in the past two years, we've laid out our plans to improve code search and shown off the technology that enabled us to do so. And today, our new code search and code view are generally available to all users on GitHub.com. Our goal with the new code search and code view is to enable developers to quickly search, navigate and understand their code, put critical information into context, and ultimately make them more productive. To achieve that, we've brought three powerful new capabilities to GitHub.com. First, an entirely redesigned search interface, with suggestions, completions, and the ability to slice and dice the results. Second, we've built a new code search engine, completely from scratch. It is incredibly fast (about twice as fast as the old code search), far more capable (supporting substring queries, regular expressions, and symbol search), and understands code, putting the most relevant results first. The new code search UI on GitHub.com And third, we've totally redesigned GitHub's code view, tightly integrating search, browsing, and code navigation. The new code view UI on GitHub.com GitHub code search puts the world's code at your fingertips. Let's take a look at what you can do with it. Fixing a bug Imagine that a user complains that they received an error message from your service saying "query is not satisfiable." You're not sure which system produced this error message, or which repository the code is in. Without code search, you might have to clone a bunch of repositories and grep through them, or ask a knowledgeable coworker. But with code search, you can instantly search across all of an organization's code at once: Search input containing the query org:github "query is not satisfiable" A single code search result for the term "query is not satisfiable" Code view showing the definition of the queryErrorIsNothing constant This gives back just one result. In it, there's a constant called queryErrorIsNothing which contains the error string. In the symbols pane, you can see the definition of the constant, and that it's used in two places. One usage is here in this file, and another is in a test. If you check where it's used, you can see why this error is emitted. And by navigating to the test, you can see an example of a query that causes the problem! Now you have a good understanding of the cause of this error, and even have an example test showing how to trigger it. From here, you could pull up a codespace and dig in deeper, and maybe use GitHub Copilot to help write another test. Finding a configuration Imagine your company uses Kubernetes, and the infrastructure team says that they're running out of memory in their cluster. How much memory are your services requesting? Can you cut back? Try searching across your team's code for YAML configuration files containing the word "memory": Search results for the query saved:blackbird lang:yaml memory Immediately, you can see the Kubernetes configuration files for our team's services, and how much memory they have. You can send a link to this search directly to the infrastructure team, and start a conversation about how much memory is allocated for those services. Finding a vulnerability If your team uses React, you might be familiar with the prop dangerouslySetInnerHTML. That prop allows you to directly inject HTML into an element using a string. But as its name implies, it can be dangerous! If the string being injected into the DOM is untrusted, it could cause a security vulnerability. Let's search for usages across github/github, which is the code behind GitHub.com: Search results for the query repo:github/github dangerouslySetInnerHTML You can immediately see a few results. Some of these are linter rules forbidding the use of dangerouslySetInnerHTML--that's great! But here's a component that might be vulnerable, called IssuesShow. By viewing this component in the code view, you can see its usages by clicking on the name of the symbol. Looks like it's used in just one other file. Here you can see the exact route that is used to render this component--and, luckily, it's part of our sandbox testing environment, so we know it's safe. The symbols pane, showing the definition and usages of the ShowIssuesPage component A new era of code intelligence Our goal with the new code search and code view is to enable developers to quickly find critical information scattered across their codebase, put that information into context, and ultimately make them more productive. And this launch is just the beginning--GitHub is infusing intelligence into every aspect of software development. Thanks again to the many users who provided invaluable feedback throughout the beta! If you spot a bug, or have suggestions on how to improve GitHub code search or code view, please share your feedback with us in this discussion. Tags: * code navigation, * code search, * code view The GitHub Insider Newsletter Get the best of GitHub. Once a month. Directly to your inbox. Subscribe More on code navigation Bringing code navigation to communities Bringing code navigation to communities Thanks to the efforts of the Elixir community, GitHub supports code navigation for Elixir repositories. Read how favorite language can add this support too! Patrick Thomson Introducing stack graphs Precise code navigation is powered by stack graphs, a new open source framework that lets you define the name binding rules for a programming language. Douglas Creager Precise code navigation for Python, and code navigation in pull requests Code navigation is now available in PRs, and code navigation results for Python are now more precise. Douglas Creager More on code search The technology behind GitHub's new code search The technology behind GitHub's new code search A look at what went into building the world's largest public code search index. Timothy Clem A better way to search, navigate, and understand code on GitHub Reading code is a hugely important task for developers. That's why we built GitHub's new code search--to help developers search, navigate, and understand code written by them, their team, and the world. Ryan J. Salva A brief history of code search at GitHub This blog post tells the story of why we built a new search engine optimized for code. Pavel Avgustinov Related posts Web Summit Rio 2023: Building an app in 18 minutes with GitHub Copilot X Engineering Web Summit Rio 2023: Building an app in 18 minutes with GitHub Copilot X GitHub CEO Thomas Dohmke demonstrated the power of GitHub Copilot X live on stage. Thomas Dohmke Dependabot relieves alert fatigue from npm devDependencies Open Source Dependabot relieves alert fatigue from npm devDependencies A new alert rules engine for Dependabot leverages alert metadata to identify and auto-dismiss up to 15% of alerts as false positives. Eric Tooley Private vulnerability reporting now generally available Product Private vulnerability reporting now generally available Open source maintainers and security researchers embrace a new best practice to report and fix vulnerabilities. Eric Tooley & Kate Catlin Explore more from GitHub Product Product Updates on GitHub products and features, hot off the press. Learn more The ReadME Project The ReadME Project Stories and voices from the developer community. Learn more GitHub Issues GitHub Issues Project planning for developers and teams. Learn more Work at GitHub! Work at GitHub! Check out our current job openings. Learn more Subscribe to The GitHub Insider A newsletter for developers covering techniques, technical guides, and the latest product innovations coming from GitHub. [ ] Subscribe [ ] Yes please, I'd like GitHub and affiliates to use my information for personalized communications, targeted advertising and campaign effectiveness. See the GitHub Privacy Statement for more details. Subscribe Product * Features * Security * Enterprise * Customer Stories * Pricing * Resources Platform * Developer API * Partners * Atom * Electron * GitHub Desktop Support * Docs * Community Forum * Training * Status * Contact Company * About * Blog * Careers * Press * Shop * GitHub on Twitter * GitHub on Facebook * GitHub on YouTube * GitHub on Twitch * GitHub on TikTok * GitHub on LinkedIn * GitHub's organization on GitHub * (c) 2023 GitHub, Inc. * Terms * Privacy