Sahih al-Bukhari, Book 70, Hadith 80 (In-Book) ⓘ
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."
حَدَّثَنَا مُسَدَّدٌ، حَدَّثَنَا عَبْدُ الْوَارِثِ، عَنْ عَبْدِ الْعَزِيزِ، قَالَ قِيلَ لأَنَسٍ مَا سَمِعْتَ النَّبِيَّ صلى الله عليه وسلم فِي الثُّومِ فَقَالَ " مَنْ أَكَلَ فَلاَ يَقْرَبَنَّ مَسْجِدَنَا " .
also referenced under: Hadith 5451 (DarusSalam) & Volume 7, Book 65, Hadith 362 (USC-MSA)