You can search globally across all of GitHub, or scope your search to a particular repository or organization. For more information, see About searching on GitHub.
You can only search code using these code search qualifiers. Search qualifiers specifically for repositories, users, or commits, will not work when searching for code.
Tip
- This article contains links to example searches on the GitHub.com website, but you can use the same search filters in any GitHub platform. In the linked example searches, replace
github.comwith the hostname for your GitHub platform. - For a list of search syntaxes that you can add to any search qualifier to further improve your results, see Understanding the search syntax.
- Use quotations around multi-word search terms. For example, if you want to search for issues with the label "In progress," you'd search for
label:"in progress". Search is not case sensitive.
Considerations for code search
Due to the complexity of searching code, there are some restrictions on how searches are performed:
- You must be signed into a personal account on GitHub to search for code across all public repositories.
- Code in forks is only searchable if the fork has more stars than the parent repository, and the forked repository has at least one pushed commit after being created. Forks with fewer stars than the parent repository or no commits are not indexed for code search. To include forks with more stars than their parent and at least one pushed commit in the search results, you will need to add
fork:trueorfork:onlyto your query. For more information, see Searching in forks. - Only the default branch is indexed for code search.
- Only files smaller than 5 MB are searchable.
- Only the first 500 KB of each file is searchable.
- Up to 4,000 private and internal repositories are searchable. These 4,000 repositories will be the most recently updated of the first 10,000 private and internal repositories that you have access to.
- Only repositories with fewer than 500,000 files are searchable.
- Archived repositories are not searchable.
- Except with
filenamesearches, you must always include at least one search term when searching source code. For example, searching forlanguage:javascriptis not valid, whileamazing language:javascriptis. - At most, search results can show two fragments from the same file, but there may be more results within the file.
- You can't use the following wildcard characters as part of your search query:
. , : ; / \ ` ' " = * ! ? # $ & + ^ | ~ < > ( ) { } [ ] @. The search will simply ignore these symbols.
Search by the file contents or file path
With the in qualifier you can restrict your search to the contents of the source code file, the file path, or both. When you omit this qualifier, only the file contents are searched.
| Qualifier | Example |
|---|---|
in:file | octocat in:file matches code where "octocat" appears in the file contents. |
in:path | octocat in:path matches code where "octocat" appears in the file path. |
in:file,path | octocat in:file,path matches code where "octocat" appears in the file contents or the file path. |
Search within a user's or organization's repositories
To search the code in all repositories owned by a certain user or organization, you can use the user or org qualifier. To search the code in a specific repository, you can use the repo qualifier.
| Qualifier | Example |
|---|---|
user:USERNAME | user:defunkt extension:rb matches code from @defunkt that ends in .rb. |
org:ORGNAME |