How to search on github for exact matches (e.g. quotes for google)

I can search for exact matches from Google using quotes like "system <<-" . How to do a similar thing for github? I can not make it work.

+177
github search
Oct 17 '14 at 21:17
source share
5 answers

You can’t Official GitHub search rules :

Due to the complexity of the code search, there are several restrictions on the search:

  • Only the default branch is considered. In most cases, this will be the main branch.
  • Only files smaller than 384 KB are searchable.
  • You should always include at least one search term when searching for source code. For example, a search for language:go invalid, and amazing language:go is.
  • In most cases, the search results may show two fragments from the same file, but this file may have more results.
  • You cannot use the following wildcard characters as part of your search query :
    .,: ; /\ ' ' " = * !? # $ & + ^ | ~ < > ( ) { } [ ]
    The search will simply ignore these characters.



Temporary solution:

If you need to search in a single repository, you can clone it locally and use grep to find the string exactly:

 grep -r "system <<-" /repository_dir 
+108
Oct. 20 '15 at 13:12
source share

You can directly use Google.

How about this?

 "your_string_to_search" site::https://github.com "your_string_to_search" site::https://gist.github.com 
+33
Mar 23 '16 at 15:47
source share

Today I tried to find the exact match of the filter class in files named logback.xml in any repo on Github. And I came up with the following query that did the job.

 "filter class" in:file filename:logback.xml 

To enable exact match with quotes, you need to follow your search with the "in: file" modifier. The matches are not entirely accurate, the word "class" should follow the word "filter", but it seems that there can be 0 or more spaces or characters between the two words.

+12
Sep 17 '15 at 19:07
source share

If you add @ mrgloom's answer , if you are looking for code in a specific programming language in Github using Google, you can do something similar in the Google search bar:

  • specify the specific string you are looking for using the "intext:" search operator
  • add the programming language you are interested in using the operator "ext:" (ie, "ext: py", "ext: R", "ext: rb", etc.)
  • search all public repositories on Github using the site operator: mentioned by mrgloom.

Example:

 intext:"%% 2 == 0" ext:R site:github.com 

Google Results from the example

+1
Jun 17 '19 at 1:44
source share

If your package is in Debian, you can use their search for code that supports regular expressions: https://codesearch.debian.net/

0
Jun 06 '18 at 8:12
source share



All Articles