Abdullah bin Masud reported,

A man asked, "Messenger of Allah, will we be held accountable for what we did during the days of ignorance?"He replied, "Whoever does well in Islam will not be held accountable for what he did in the days of ignorance, but whoever does evil in Islam will be held accountable for both the former and the latter."

Bukhari 6921

Sahih

حدثنا خلاد بن يحيى حدثنا سفيان عن منصور والأعمش عن أبي وائل

عن ابن مسعود رضي الله عنه قال

قال رجل يا رسول الله أنؤاخذ بما عملنا في الجاهلية قال من أحسن في الإسلام لم يؤاخذ بما عمل في الجاهلية ومن أساء في الإسلام أخذ بالأول والآخر

البخاري 6921صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Demanding repentance from apostates and obstinate disbelievers and fighting them
Chapter
Sin of associating partners with Allah and its punishment in this world and the Hereafter
Numbering
Darussalam 6921
Bukhari 6921