The Messenger of Allah ﷺ came upon Umar while he was riding with a group and swearing by his father. The Messenger of Allah ﷺ said, "Allah forbids you from swearing by your fathers. Whoever swears, let him swear by Allah or remain silent."
حدثنا هناد حدثنا عبدة عن عبيد الله بن عمر عن نافع
أن رسول الله ﷺ أدرك عمر وهو في ركب وهو يحلف بأبيه فقال رسول الله ﷺ إن الله ينهاكم أن تحلفوا بآبائكم ليحلف حالف بالله أو ليسكت
Agreed upon. Muslim narrated it in the Book of Oaths, Chapter on the prohibition of swearing by anything other than Allah Almighty, hadith 4/1646, from the hadith of Ubaydullah bin Umar, and Bukhari, hadith 6646, from the hadith of Nafi through him.