Language:
كتاب مناقب الأنصار
63  
Merits of the Helpers in Madinah (Ansaar)
(52)
Chapter: The coming of the Jews to the Prophet (saws) on his arrival at Al-Madina
(52)
باب إِتْيَانِ الْيَهُودِ النَّبِيَّ صلى الله عليه وسلم حِينَ قَدِمَ الْمَدِينَةَ
Sahih al-Bukhari 3944

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 168
USC-MSA web (English) reference : Vol. 5, Book 58, Hadith 280
  (deprecated numbering scheme)