Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:2:224

And do not make ˹your oath by˺ Allah an excuse against being righteous and fearing Allah and making peace among people. And Allah is Hearing and Knowing.  

Do not make God, by swearing in His Name, a hindrance, a cause of impediment, in your oaths, that is, setting up ˹such impediments˺ by swearing in His Name frequently, so as not, to be pious and God-fearing; in such instances oaths are hateful, and result in perjury, which requires a redemption, effected by doing the opposite ˹of the oath˺, such as performing righteous deeds and so forth, which constitute an act of obedience; and to put things right between people: this means, do not be prevented from doing righteous deeds, as mentioned, just because you swore against them; nay, do them and make redemption; ˹this understanding of the verse is˺ justified by the reason for its revelation, namely, their refraining from such deeds; surely God is All-Hearing, of what you say, Knower, of your circumstances.
القرآن:٢:٢٢٤

وَلَا تَجْعَلُوا اللَّهَ عُرْضَةً لِأَيْمَانِكُمْ أَنْ تَبَرُّوا وَتَتَّقُوا وَتُصْلِحُوا بَيْنَ النَّاسِ ۗ وَاللَّهُ سَمِيعٌ عَلِيمٌ  

{ولا تجعلوا الله} أي الحلف به {عرضة} علة مانعة {لأيمانكم} أي نصيبا لها بأن تكثروا الحلف به {أن} لا {تبروا وتتقوا} فتكره اليمين على ذلك ويسن فيه الحنث ويكفِّر بخلافها على فعل. البر ونحوه فهي طاعة {وتصلحوا بين الناس} المعنى لا تمتنعوا من فعل ما ذكر من البر ونحوه إذا حلفتم عليه بل ائتوه وكفِّروا لأن سبب نزولها الامتناع من ذلك {والله سميع} لأقوالكم {عليم} بأحوالكم.