How to Search on Github to Get Exact String Matches, Including Special Characters
I Can Search Exact Matches from Google by Using Quotes Like "System
I can search exact matches from Google by using quotes like "system <<-".
How can I do the same thing for GitHub?
10 Answers
You couldn't (before 2022). The official GitHub searching rules:
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
- Only the default branch is considered. In most cases, this will be the master branch.
- Only files smaller than 384 KB are searchable.
- Only repositories with fewer than 500,000 files are searchable.
- You must always include at least one search term when searching source code. For example, searching for
language:gois not valid, whileamazing language:gois.- 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.
Update: GitHub supports literal strings now, but you can also try some more powerful ways below.
Must Read
Try Sourcegraph
For complex search with regex support try Sourcegraph.