It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with both of them) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever has eaten (raw) garlic or onion should keep away from us, or stay away from our mosque, and remain in his house."
Hadith Referenceصحيح ابن خزيمه / جماع أبواب العذر الذى يجوز فيه ترك إتيان الجماعة / 1664