2

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?

1

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

  • Please edit your answer including a link to the referring GitHub support answer/page as well. – marikamitsos Sep 27 at 17:39
  • @marikamitsos done – Yet Another User Sep 27 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.