I heard the Messenger of Allah ﷺ say, "A servant committed a sin and said, 'My Lord, I have committed a sin, so forgive me.' His Lord said, 'My servant knows that he has a Lord who forgives sins and holds people accountable for them. I have forgiven My servant.'Then he remained as long as Allah willed, then he committed another sin and said, 'My Lord, I have committed a sin, so forgive it for me.' His Lord said, 'My servant knows that he has a Lord who forgives sins and holds people accountable for them. I have forgiven My servant.'"
حدثنا عفان قال حدثنا همام حدثنا إسحاق بن عبد الله بن أبي طلحة قال كان بالمدينة قاص يقال له عبد الرحمن بن أبي عمرة قال فسمعته يقول سمعت
سمعت رسول الله ﷺ يقول إن عبدا أصاب ذنبا فقال أي رب أذنبت ذنبا فاغفر لي فقال ربه عز وجل علم عبدي أن له ربا يغفر الذنب ويأخذ به فغفر له ثم مكث ما شاء الله ثم أذنب ذنبا آخر فقال أي رب أذنبت ذنبا فاغفره لي فقال ربه علم عبدي أن له ربا يغفر الذنب ويأخذ به قد غفرت لعبدي
Its isnad is sahih. Bukhari reported it, 9/178, in the book of Tawhid, regarding the words of Allah "They want to change the words of Allah" [Fath 48:15], and Muslim, 4/2112, no. 2758, in the book of Repentance, on the acceptance of repentance.