59

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
Limon Monte
  • 52,539
  • 45
  • 182
  • 213

3 Answers3

86

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

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
Nilay Vishwakarma
  • 3,105
  • 1
  • 27
  • 48
33

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

ADJenks
  • 2,973
  • 27
  • 38
  • 1
    Thank you! I needed to search for term "search" but exclude "replace" to find issues about "search" functionality (and NOT "search & replace" functionality). – skplunkerin Mar 19 '20 at 13:32
  • 3
    Attention: GitHub is case-sensitive in this case, `NOT` has to be uppercase. – Melebius Feb 10 '22 at 09: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 '22 at 04:12
  • This doesn't seem to work anymore – Danielo515 Apr 15 '23 at 11:38
7

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

Arsham Arya
  • 1,461
  • 3
  • 17
  • 25