Jabir bin Abdullah reported,

In Harmala's narration, he stated that the Messenger of Allah ﷺ said, "Whoever eats garlic or onion, let him keep away from us," or he said, "let him keep away from our mosque and remain in his house."A pot containing some green vegetables was once brought to him. He noticed an odor coming from it and asked about it. He was informed of the vegetables it contained, so he said, "Bring it close to one of his companions."When the companion saw it, he disliked eating from it. The Prophet ﷺ said, "Eat, for I converse with one with whom you do not converse."

Muslim 1253

Sahih

و حدثني أبو الطاهر وحرملة قالا أخبرنا ابن وهب أخبرني يونس عن ابن شهاب قال حدثني عطاء بن أبي رباح أن

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

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

مسلم 1253صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Mosques and places of prayer
Chapter
Prohibition on those who have eaten garlic, onions, leeks, or similar from attending the masjid
Numbering
Darussalam 1253
Muslim 1253