4

Let's say i want to search a repo for

def fc

When i type that in, I get hits for "def" and hits for "fc" and I have no idea what order they're in.

If I search for

"def fc"

then it gets a little better, I get hits where i have "def" and then a space, or brackets, or other non-words, and then "fc". This still isn't what I want though - I just want "def" and then a space and then "fc".

It gets worse if I try to search for html - searching for

"<input" 

only yields the word input, which can get quite heavy, and this gets worse if I search for

"<input type="text"" 

because now i have no idea how the " works. I looked at the imposing github search help page, https://help.github.com/articles/searching-code/ but to no avail.

bharal
  • 15,461
  • 36
  • 117
  • 195

2 Answers2

0

GitHub can't do exact searches. Clone the repo locally and use git grep "def fc"

More about GitHub searching here.

staxim
  • 1,328
  • 14
  • 15
0

Since Dec. 2021, you can search for the symbol fc (exact match), for a limited set of supported languages.
(As of Dec. 2021: C#, Python, Go, Java, JavaScript, TypeScript, PHP, Protocol Buffers, Ruby, and Rust)

You must do your search, for now, on cs.github.com.

Improving GitHub code search

(from Pavel Avgustinov)

Refine your results using filters like language:, path:, extension:, and Boolean operators (OR, NOT).
Search for definitions of a symbol with symbol:.

Symbol search is based on parsing your code using the open source Tree-sitter.

See Symbol qualifier

In your case, for instance:

language:javascript symbol:fc
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250