It is narrated from Hazrat Abu Huraira (may Allah be pleased with him) that the Noble Prophet (peace and blessings be upon him) smelled the odor of garlic in the mosque, so the Noble Prophet (peace and blessings be upon him) said: Whoever eats from this foul tree (garlic) should not come near our mosque.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 9545
Hadith Gradingحکم دارالسلام:حدیث صحیح ، وھذا إسناد حسن ، م : 563