Madan bin Abu Talha reported,

Umar bin Khattab stood up to deliver the sermon on Friday, or he gave a sermon on Friday, and after praising Allah and glorifying Him, he said, "People, you eat two plants that I consider nothing but offensive, this garlic and this onion. In the time of the Messenger of Allah ﷺ, if a man was found to have their smell on him, he would be taken by the hand and led out to al-Baqi. So whoever must eat them, let him kill their smell by cooking them."

Ibn Majah 1014

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا إسمعيل ابن علية عن سعيد بن أبي عروبة عن قتادة عن سالم بن أبي الجعد الغطفاني

عن معدان بن أبي طلحة اليعمري

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

ابن ماجه 1014صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
One who eats garlic should not approach the masjid
Numbering
Darussalam 1014
Ibn Majah 1014