Search excluding file name on GitHub

github

Situation: You are trying to find the usages of a feature of some common framework, and want to only find client code instead of 1000 copies of the library itself. Further compounding the problem is that you can't exclude forks to get rid of these copies since the framework source is not officially on GitHub, so all the copies are not recorded as forks.

You know that all the copies of the framework source have their references in MtpConstants.java, so all you need to do is exclude that file from your searches and you'll get rid of the framework copies.

I've tried:

FORMAT_MS_POWERPOINT_PRESENTATION, set language to Java: 3500 results.

FORMAT_MS_POWERPOINT_PRESENTATION NOT filename:MtpConstants.java: 0 results even though there should be some

FORMAT_MS_POWERPOINT_PRESENTATION AND NOT filename:MtpConstants.java: same

FORMAT_MS_POWERPOINT_PRESENTATION AND (NOT filename:MtpConstants.java): finds only results in MtpConstants.java, the opposite of the intended effect.

Is there a working way to exclude file names in GitHub search?

Best Answer

According to GitHub support, this is accomplished by using the - sign:

FORMAT_MS_POWERPOINT_PRESENTATION -filename:MtpConstants.java

and I can confirm that this indeed works.

Documentation

Search by filename: https://help.github.com/en/articles/searching-code#search-by-filename

Excluding results: https://help.github.com/en/articles/understanding-the-search-syntax#exclude-certain-results