Sahih al-Bukhari 5451
Sahih al-Bukhari · Book 70: Food, Meals · The eating of garlic or other (bad smelling vegetables).
Narrated `Abdul `Aziz:
حَدَّثَنَا مُسَدَّدٌ ، حَدَّثَنَا عَبْدُ الْوَارِثِ ، عَنْ عَبْدِ الْعَزِيزِ ، قَالَ قِيلَ لأَنَسٍ مَا سَمِعْتَ النَّبِيَّ صلى الله عليه وسلم فِي الثُّومِ فَقَالَ " مَنْ أَكَلَ فَلاَ يَقْرَبَنَّ مَسْجِدَنَا " .
It was said to Anas "What did you hear the Prophet (ﷺ) saying about garlic?" Anas replied, "Whoever has eaten (garlic) should not approach our mosque."