Mughira bin Shuba reported,

I ate some garlic, then came to the place where the Prophet ﷺ was praying, after one rakah had already passed. When I entered the mosque, the Prophet ﷺ caught the smell of garlic. When the Messenger of Allah ﷺ had finished his prayer, he said, "Whoever has eaten from this plant should not come near us until its smell, or his smell, has gone away."When the prayer was over, I came to the Messenger of Allah ﷺ and said, "Messenger of Allah, by Allah, give me your hand."He gave me his hand, and I slipped it inside the sleeve of my shirt up to my chest, where he found my chest tightly bound. He said, "You have a valid excuse."

Azami 3150

Sahih

عن المغيرة بن شعبة قال

أكلت ثوما، فأتيت مصلى النبي ﷺ، وقد سبقت بركعة، فلما دخلت المسجد وجدالنبي ﷺ ريح الثوم. فلما قضى رسول الله ﷺ صلاته قال: من أكل هذه الشجرة فلا يقرب حتى يذهب ريحها أو ريحه فلما قضيت الصلاة جئت إلى رسول الله ﷺ فقلت: يا رسول الله! والله تعطيني يدك، قال: فأدخلت يده في كم قميصي إلى صدري، فإذا أنا معصوب الصدر، قال: إن لك عذرا.

الأعظمي 3150صحيح
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 3150 (2nd edition)
Azami 3150