Following up with good deeds after committing sins may even dissolve the sin of having external physical intimacy someone other than your spouse
A man came to the Prophet ﷺ and said: "I fondled a woman who lives on the outskirts of Madinah, and I did with her what is less than intercourse, and here I am, so judge in my case as you will." So ʿUmar said to him: "Allah covered ˹your sins˺, so you should have ˹kept them˺ covered yourself." The Messenger of Allah ﷺ did not give him any reply.
The man left but the Messenger of Allah ﷺ sent a man after him to call him back. He recited to him: "And perform Salāh, at the two ends of the day and in some hours of the night. Verily, the good deeds remove the evil deeds. That is a reminder for the mindful (Hūd 11:114)" until the end of the āyah. A man among the people said: "Is this specific for him?" He ﷺ said: 'No. Rather for all of the people."
جَاءَ رَجُلٌ إِلَى النَّبِيِّ ﷺ فَقَالَ: إِنِّي عَالَجْتُ امْرَأَةً فِي أَقْصَى الْمَدِينَةِ، وَإِنِّي أَصَبْتُ مِنْهَا مَا دُونَ أَنْ أَمَسَّهَا وَأَنَا هَذَا، فَاقْضِ فِيَّ مَا شِئْتَ۔ فَقَالَ لَهُ عُمَرُ: لَقَدْ سَتَرَكَ اللَّهُ لَوْ سَتَرْتَ عَلَى نَفْسِكَ۔ فَلَمْ يَرُدَّ عَلَيْهِ رَسُولُ اللَّهِ ﷺ شَيْئًا۔
فَانْطَلَقَ الرَّجُلُ فَأَتْبَعَهُ رَسُولُ اللَّهِ ﷺ رَجُلاً فَدَعَاهُ فَتَلاَ عَلَيْهِِمِ {أَقِمِ الصَّلاَةَ طَرَفَيِ النَّهَارِ وَزُلَفًا مِنَ اللَّيْلِ إِنَّ الْحَسَنَاتِ يُذْهِبْنَ السَّيِّئَاتِ ذَلِكَ ذِكْرَى لِلذَّاكِرِينَ} إِلَى آخِرِ الآيَةِ۔ فَقَالَ رَجُلٌ مِنَ الْقَوْمِ: هَذَا لَهُ خَاصَّةً؟ قَالَ: «لاَ، بَلْ لِلنَّاسِ كَافَّةً۔»