Language:
كتاب الأيمان والنذور
83  
Oaths and Vows
(18)
Chapter: To swear something not in one's power; to swear to do an act disobedience; to take an oath in anger.
(18)
باب الْيَمِينِ فِيمَا لاَ يَمْلِكُ، وَفِي الْمَعْصِيَةِ، وَفِي الْغَضَبِ
Sahih al-Bukhari 6680

Narrated Abu Musa Al-Ash`ari:

I went along with some men from the Ash-ariyin to Allah's Messenger (ﷺ) and it happened that I met him while he was in an angry mood. We asked him to provide us with mounts, but he swore that he would not give us any. Later on he said, "By Allah, Allah willing, if ever I take an oath (to do something) and later on I find something else better than the first, then I do the better one and give expiation for the dissolution of my oath."

حَدَّثَنَا أَبُو مَعْمَرٍ، حَدَّثَنَا عَبْدُ الْوَارِثِ، حَدَّثَنَا أَيُّوبُ، عَنِ الْقَاسِمِ، عَنْ زَهْدَمٍ، قَالَ كُنَّا عِنْدَ أَبِي مُوسَى الأَشْعَرِيِّ قَالَ أَتَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم فِي نَفَرٍ مِنَ الأَشْعَرِيِّينَ، فَوَافَقْتُهُ وَهْوَ غَضْبَانُ فَاسْتَحْمَلْنَاهُ، فَحَلَفَ أَنْ لاَ يَحْمِلَنَا ثُمَّ قَالَ ‏ "‏ وَاللَّهِ إِنْ شَاءَ اللَّهُ لاَ أَحْلِفُ عَلَى يَمِينٍ فَأَرَى غَيْرَهَا خَيْرًا مِنْهَا، إِلاَّ أَتَيْتُ الَّذِي هُوَ خَيْرٌ وَتَحَلَّلْتُهَا ‏"‏‏.‏
Reference : Sahih al-Bukhari 6680
In-book reference : Book 83, Hadith 57
USC-MSA web (English) reference : Vol. 8, Book 78, Hadith 671
  (deprecated numbering scheme)