62

In this search query (test it live ↗) I'm searching for:

  • all pull requests
  • by user limonte (me)
  • for the vaadin company

How can I search for all my pull requests except (logical NOT) those for vaadin company?


These two options I tried without success:

  • is:pr author:limonte user:!vaadin
  • is:pr author:limonte user:NOT vaadin

3 Answers 3

92
+50

Prefixing any search qualifier with a - excludes all results that are matched by that qualifier.

For example, you might be interested in finding all "cats" repositories with more than 10 stars that are not written in JavaScript:

cats stars:>10 -language:javascript

You might also want to find all issues mentioning @defunkt that are not in repositories in the GitHub organization:

mentions:defunkt -user:github

The answer for your question is:

is:pr author:limonte -user:vaadin


For more refer the GitHub Search Syntax

5
  • @NilayVishwakarma how can I negate with repository name, any idea on this?
    – Shivankar
    Feb 18, 2019 at 11:24
  • @Shiv try something like this: is:pr author:limonte -repo:sweetalert2/sweetalert2 Feb 18, 2019 at 11:38
  • 2
    @NilayVishwakarma yep it works but in the above, we end up giving the org/repo-name or user/repo-name to exclude the result any possible way that I can remove just based on repo-name, without passing the organisation or user? something like -repo:jquery to remove to all repo's with the name jquery
    – Shivankar
    Feb 18, 2019 at 23:16
  • 2
    I don't think GitHub supports this. Mar 11, 2019 at 4:48
  • 1
    This doesn't seem to work in the notification search yet :( May 31, 2021 at 10:24
36

Use "NOT" for excluding words when searching a whole repository.

hello NOT world matches repositories that have the word "hello" but not the word "world."

I got tired of getting unit tests in my searches, so I was searching like so:

NOT test in:path AND "search-term" in:file

Use "-QUALIFIER" for excluding results with a specific qualifier.

cats stars:>10 -language:javascript matches repositories with the word "cats" that have more than 10 stars but are not written in JavaScript.


Quotes from: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#exclude-certain-results

Archived: https://web.archive.org/web/20221014142718/https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#exclude-certain-results

4
  • 1
    Thank you! I needed to search for term "search" but exclude "replace" to find issues about "search" functionality (and NOT "search & replace" functionality). Mar 19, 2020 at 13:32
  • 3
    Attention: GitHub is case-sensitive in this case, NOT has to be uppercase.
    – Melebius
    Feb 10, 2022 at 9:53
  • NOT test in:path AND "abc" in:file presents a Code Search could not process your request, please try different search criteria. It seems you cant combine flags. Doing "abc" in:file -test` worked though, but it might exclude more than intended. oh well.
    – 9 Guy
    Jun 16, 2022 at 4:12
  • This doesn't seem to work anymore
    – Danielo515
    Apr 15 at 11:38
10

I think this would be helpful for everyone who gets confused between different ways of narrowing down the results:


Use NOT for words

If you're trying to exclude a certain word, you should use NOT keyword before that.

In my case, I was trying to find microservice projects (not frameworks) written in Go.

microservice NOT framework language:Go

microservice NOT framework NOT library language:Go

including white space:

cats NOT "hello world"


Use - for qualifiers

If you're trying to exclude specific qualifiers you should use -:

cats stars:>10 -language:javascript => any language except javascript

mentions:defunkt -org:github => any organization except github


Source: https://docs.github.com/en/search-github/getting-started-with-searching-on-github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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