The Messenger of Allah ﷺ found 'Umar al-Khattab in a caravan while he was swearing by his father. So he said: Allah forbids you to swear by forefathers. If anyone swears, he must swear by Allah or keep silence.
أَنَّ رَسُولَ اللَّهِ ﷺ أَدْرَكَهُ وَهُوَ فِي رَكْبٍ وَهُوَ يَحْلِفُ بِأَبِيهِ فَقَالَ إِنَّ اللَّهَ يَنْهَاكُمْ أَنْ تَحْلِفُوا بِآبَائِكُمْ فَمَنْ كَانَ حَالِفًا فَلْيَحْلِفْ بِاللَّهِ أَوْ لِيَسْكُتْ