Jabir bin Abdullah reported,

He reported that the Prophet ﷺ said, "Whoever eats garlic or onions should keep away from us," or he said, "should keep away from our mosque, and remain in his house."The Prophet ﷺ was once brought a pot containing some greens and vegetables. He noticed an odor coming from it and asked about it, and was told what vegetables were in it. He said, "Bring it close to one of his companions who was with him." When the man saw it, he disliked eating it. The Prophet ﷺ said, "Eat, for I converse with one with whom you do not converse."

Azami 3144

Sahih

عن جابر بن عبد الله

زعم أن النبي ﷺ قال: من أكل ثوما أو بصلا فليعتزلنا- أو قال: فليعتزل مسجدنا- وليقعد في بيته وأن النبي ﷺ أتى بقدر فيه خضروات من بقول فوجد لها ريحا، فسأل فأخبر بما فيها من البقول فقال: قربوها إلى بعض أصحابه كان معه، فلما رآه كره أكلها قال: كل، فإني أناجي من لا تناجي.

الأعظمي 3144صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Mosques
Section
Prohibition of coming to the mosques after eating garlic, onions, and leeks
Numbering
Jami al-Kamil 3144 (2nd edition)
Azami 3144