Messenger of Allah ﷺ met ʿUmar bin Al-Khattab while the latter was going with a group of camel-riders, and he was swearing by his father. The Prophet ﷺ said, "Lo! Allah forbids you to swear by your fathers, so whoever has to take an oath, he should swear by Allah or keep quiet." (Using translation from Bukhārī 6646)
أَنَّ رَسُولَ اللَّهِ ﷺ أَدْرَكَ عُمَرَ بْنَ الْخَطَّابِ وَهُوَ يَسِيرُ فِي رَكْبٍ وَهُوَ يَحْلِفُ بِأَبِيهِ فَقَالَ رَسُولُ اللَّهِ ﷺ «إِنَّ اللَّهَ يَنْهَاكُمْ أَنْ تَحْلِفُوا بِآبَائِكُمْ فَمَنْ كَانَ حَالِفًا فَلْيَحْلِفْ بِاللَّهِ أَوْ لِيَصْمُتْ»