(52) باب إِتْيَانِ الْيَهُودِ النَّبِيَّ صلى الله عليه وسلم حِينَ قَدِمَ الْمَدِينَةَ
Narrated `Abdullah bin `Abbas:
The Prophet (ﷺ) used to keep his hair falling loose while the pagans used to part their hair, and the People of the Scriptures used to keep their hair falling loose, and the Prophet (ﷺ) liked to follow the People of the Scriptures in matters about which he had not been instructed differently, but later on the Prophet (ﷺ) started parting his hair.
Reference: Sahih al-Bukhari 3944
In-book reference: Book 63, Hadith 169
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 5, Book 58, Hadith 280