The Messenger of Allah ﷺ ordered that dogs be killed, but then he said, "What is the matter with them and with the dogs?" He then granted an exemption for the hunting dog and the sheepdog. Ibn Hatim, in his version of the report from Yahya, said, "He granted an exemption for the sheepdog, the hunting dog, and the dog that guards crops."
و حدثنيه يحيى بن حبيب حدثنا خالد يعني ابن الحارث ح و حدثني محمد بن حاتم حدثنا يحيى بن سعيد ح و حدثني محمد بن الوليد حدثنا محمد بن جعفر ح و حدثنا إسحق بن إبراهيم أخبرنا النضر ح و حدثنا محمد بن المثنى حدثنا وهب بن جرير كلهم عن شعبة بهذا الإسناد و قال ابن حاتم في حديثه عن يحيى ورخص في كلب الغنم والصيد والزرع