The tribe of Banu Salama wanted to leave their homes and move closer to the mosque. When this reached the Messenger of Allah ﷺ, he disliked the idea of parts of Madinah becoming deserted, so he said, "Banu Salama, will you not seek the reward for your footsteps to the mosque?"They replied, "Of course, Messenger of Allah."So they remained in their homes.
حدثنا ابن أبي عدي عن حميد
أن بني سلمة أرادوا أن يتحولوا من منازلهم فيسكنوا قرب المسجد فبلغ ذلك رسول الله ﷺ وكره أن تعرى المدينة فقال يا بني سلمة ألا تحتسبون آثاركم إلى المسجد قالوا بلى يا رسول الله فأقاموا
Its chain of transmission is sahih. The hadith was also reported by Bukhari 1/167 in the Book of Prayer, chapter on counting one's steps, Muslim 1/462 no. 665 in the Book of Mosques, chapter on the merit of taking many steps to mosques, and Ibn Majah 1/258 no. 784.