عن أبي ذر قال: قال لي رسول الله صلى الله عليه وسلم: اتق الله حيثما كنت وأتبع السيئة الحسنة تمحها وخالق الناس بخلق حسن (سنن الترمذي، الرقم: 1987)
Hazrat Abu Zarr (radhiyallahu ‘anhu) reports, “Rasulullah (sallallahu ‘alaihi wasallam) once addressed me and said, ‘Fear Allah Ta‘ala wherever you may be, (if you commit an evil deed, then) carry out a good action after the wrong, as the good action will cause the effect of the sin to be erased, and deal with people with excellent character.”
Note:
It is reported in many Ahaadith that carrying out good deeds is a means of expiating sins e.g. making wudhu, performing salaah, giving sadaqah, etc. are a means of one’s sins being wiped out. Similarly, in this Hadith, mention is made that carrying out a good deed after a sin causes the effect of the sin to be erased.
It should be borne in mind that according to the Muhadditheen, these types of Ahaadith refer to minor sins. The Muhadditheen explain that as far as major sins are concerned, then tawbah is necessary. Hence, if a person has committed any major sin, then he should make tawbah and also carry out a good deed thereafter so that this will be a further compensation for the wrong that he has done.