The Messenger of Allah ﷺ came upon him while he was riding with a group and swearing by his father. He said, "Allah forbids you from swearing by your fathers. Whoever swears, let him swear by Allah or remain silent."
حدثنا أحمد بن يونس حدثنا زهير عن عبيد الله بن عمر عن نافع عن ابن عمر
أن رسول الله ﷺ أدركه وهو في ركب وهو يحلف بأبيه فقال إن الله ينهاكم أن تحلفوا بآبائكم فمن كان حالفا فليحلف بالله أو ليسكت
Narrated by Muslim, Book of Oaths, chapter on the prohibition of swearing by anything other than Allah, Most High, no. 1646, from the hadith of Ubaydullah bin Umar, and by Bukhari, Book of Manners, chapter on those who did not consider a person who said such a thing while interpreting it differently or out of ignorance to be a disbeliever, no. 6108, from the hadith of Nafi, through the same chain.