Tamim bin Tarafa reported,

A beggar came to Adi bin Hatim and asked him for help with the price of a servant, or part of the price of a servant. Adi said, "I have nothing to give you except my coat of mail and my helmet. I will write to my family instructing them to hand it over to you."The man was not satisfied with that, so Adi grew angry and said, "By Allah, I will give you nothing at all."Then the man relented and accepted the offer, but Adi said, "By Allah, were it not that I heard the Messenger of Allah ﷺ say, 'Whoever swears an oath and then sees that something else is more pious before Allah, let him pursue the more pious course,' I would not have broken my oath."

Muslim 4275

Sahih

حدثنا قتيبة بن سعيد حدثنا جرير عن عبد العزيز يعني ابن رفيع

عن تميم بن طرفة قال

جاء سائل إلى عدي بن حاتم فسأله نفقة في ثمن خادم أو في بعض ثمن خادم فقال ليس عندي ما أعطيك إلا درعي ومغفري فأكتب إلى أهلي أن يعطوكها قال فلم يرض فغضب عدي فقال أما والله لا أعطيك شيئا ثم إن الرجل رضي فقال أما والله لولا أني سمعت رسول الله ﷺ يقول من حلف على يمين ثم رأى أتقى لله منها فليأت التقوى ما حنثت يميني

مسلم 4275صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Oaths
Chapter
Recommendation for one who swore an oath then saw something better to do what is better and expiate for his oath
Numbering
Darussalam 4275
Muslim 4275