The Messenger of Allah ﷺ said, "Whoever has eaten from this plant," meaning garlic, "let him not disturb us in our mosque." In another version he said, "Let him not come near our mosque, nor disturb us with the smell of garlic."
حدثنا عبد الرزاق حدثنا معمر عن الزهري عن ابن المسيب
قال رسول الله ﷺ من أكل من هذه الشجرة يعني الثوم فلا يؤذينا في مسجدنا وقال في موضع آخر فلا يقربن مسجدنا ولا يؤذينا بريح الثوم
Its isnad is sahih. It is a repetition of 7573, where we mentioned that Muslim reported it, 1:156, through the route of Abdul-Razzaq, and this is the route of Abdul-Razzaq. The wording in Muslim agrees with the other wording, which Imam Ahmad quoted here when he said, "And in another place he said..."