How do i search github for a particular and exact term?

Viewed 6470

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.

2 Answers

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

More about GitHub searching here.

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
Related