GitHub indexes repositories you own and repositories in organizations you are a member of, whether public, private, or internal. This means that you can search across all of your repositories, in addition to the public repositories on GitHub.com that have already been indexed. Only users with permission to view your code on GitHub.com will be able to see your code in search results. Forks are indexed and searchable in the same way as other repositories.
Not all code is indexed, and you can currently only search the default branches of repositories. For more information on known limitations, see "About GitHub Code Search."
You must be logged in to a GitHub account to use code search, including for searching code in public repositories.
You can search using the search interface on GitHub.com. Using suggestions, completions, and saved searches, you can quickly find what you are looking for, often without having to fully type a query or view the search results page.
For more information about the search syntax of code search, see "Understanding GitHub Code Search syntax."
Note that the syntax and qualifiers for searching for non-code content, such as issues, users, and discussions, is not the same as the syntax for code search. For more information on non-code search, see "About searching on GitHub" and "Searching on GitHub."
In the top navigation of GitHub.com, click the search bar.
Under the search bar, you will see a list of suggestions organized by category, including recent searches and suggested repositories, teams, and projects that you have access to. You can also see a list of saved searches that you have created. For more information on saved searches, see "Creating and managing saved searches."
If you click on any of the specific suggestions, you will be taken directly to the page for that suggestion (for example, the repository or project page). If you click on a recent or saved search, depending on the type of search, the search query will appear in the search bar or you will be taken to the search results page for the search term.
Once you start typing a search query, you will see a list of completions and suggestions that match your query. You can click on a suggestion to jump to a specific location. As you type more qualifiers, you will see more specific suggestions, such as code files you can jump to directly.
After typing your query, you can also press Enter to go to the full search results view, where you can see each match and a visual interface for applying filters. For more information, see "Using the search results view."
- In the top navigation of GitHub.com, click the search bar and type
- Under the search bar, in the "Saved queries" section, click Manage saved searches.
- In the pop-up window, type both the name you want for your saved search and the query you want to save.
- To finish creating your saved search, click Create saved search.
- To see your saved search, click the search bar. Your saved search will be in the "Saved queries" section. Clicking on a saved search entry will add the query to the search bar and filter the suggestions accordingly.
- To manage a saved search, type
saved:in the search bar, then click Manage saved searches.
- To edit a saved search, to the right of the search, click .
- To delete a saved search, to the right of the search, click .
To construct a search query, as well as view and filter results, using a visual interface, you can use the search page or advanced search page. If you press Enter after typing a search query in the search bar, you will also be taken to the search results view.
On the search results view, you can navigate between different types of search results, including code, issues, pull request, repositories, and more. You can also view and use filters.
On GitHub Mobile, you can navigate to a repository and use code search on the code in that repository. Code search on GitHub Mobile uses the same syntax as code search on GitHub.com. For more information, see "About GitHub Code Search."
- On GitHub Mobile, navigate to the main page of a repository.
- Tap Code, then tap the search bar.
- Once you start typing a search query, you will see a list of completions and suggestions that match your query. You can click on a suggestion to jump to a specific location. As you type more qualifiers, you will see more specific suggestions, such as code files you can jump to directly.