The Messenger of Allah ﷺ came upon Umar bin Khattab while he was traveling with a caravan and swearing by his father. The Messenger of Allah ﷺ said, "Allah forbids you from swearing by your fathers. Whoever wishes to swear, let him swear by Allah or remain silent."
أن رسول الله ﷺ أدرك عمر بن الخطاب رضي الله عنه وهو يسير في ركب وهو يحلف بأبيه، فقال رسول الله ﷺ: إن الله ينهاكم أن تحلفوا بآبائكم، فمن كان حالفا، فليحلف بالله أو ليصمت.
Malik narrated it in "Vows and Oaths" (14) from Nafi, from Abdullah bin Umar, as mentioned.Bukhari narrated it in "Oaths and Vows" (6646) via Malik, in the same manner.Muslim narrated it in "Oaths and Vows" (1646:43) through other routes from Nafi.