The Prophet ﷺ said, "Allah forbids you from swearing by your fathers."Umar said, "By Allah, I never swore by them after that, neither speaking on my own nor quoting another."
أخبرنا محمد بن عبد الله بن يزيد وسعيد بن عبد الرحمن واللفظ له قالا حدثنا سفيان عن الزهري عن سالم عن أبيه
أن النبي ﷺ قال إن الله ينهاكم أن تحلفوا بآبائكم قال عمر فوالله ما حلفت بها بعد ذاكرا ولا آثرا
Bukhari narrated it, no. 6647, and Muslim, no. 2/1646, from the hadith of Sufyan bin Uyayna, through the same route. See the previous hadith. It is also in Kubra, no. 4708.