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:48:2

That Allah may forgive for you what preceded of your sin and what will follow and complete His favor upon you and guide you to a straight path  

that God may forgive you, by virtue of your struggle, what is past of your sin and what is to come, of it, so that your community might then desire to struggle ˹like you˺ — this ˹verse˺ also constitutes a justification of the ˹concept of the˺ infallibility (‘isma) of prophets, peace be upon them, against sin, by way of a definitive rational proof (the lām ˹in li-yaghfira, ‘that He may forgive’˺ is for ˹indicating˺ the ultimate reason ˹for the conquest˺, so that the content ˹of this latter statement˺ constitutes an effect and not the cause), and that He may perfect, by way of the mentioned victory, His favour to you and guide you, thereby, to a straight path, upon which He will confirm you — and this ˹straight path˺ is the religion of Islam;
القرآن:٤٨:٢

لِيَغْفِرَ لَكَ اللَّهُ مَا تَقَدَّمَ مِنْ ذَنْبِكَ وَمَا تَأَخَّرَ وَيُتِمَّ نِعْمَتَهُ عَلَيْكَ وَيَهْدِيَكَ صِرَاطًا مُسْتَقِيمًا  

{ليغفر لك الله} بجهادك {ما تقدم من ذنبك وما تأخر} منه لترغب أمتك في الجهاد وهو مؤول لعصمة الأنبياء عليهم الصلاة والسلام بالدليل العقلي القاطع من الذنوب واللام للعلة الغائية فمدخولها مسبب لا سبب {ويتم} بالفتح المذكور {نعمته} إنعامه {عليك ويهديك} به {صراطا} طريقا {مستقيما} يثبتك عليه وهو دين الإسلام.