Sahih Muslim , Book 30, Hadith 5768 (USC-MSA)

Ibn Abbas reported that the People of the Book used to let their hair fall (on their foreheads) and the polytheists used to part them on their heads, and Allah's Messenger liked to conform his behaviour to the People of the Book in matters in which he received no command (from God) ; so Allah's Messenger let fall his hair upon his forehead, and then he began to part it after this.

حَدَّثَنَا مَنْصُورُ بْنُ أَبِي مُزَاحِمٍ، وَمُحَمَّدُ بْنُ جَعْفَرِ بْنِ زِيَادٍ، قَالَ مَنْصُورٌ حَدَّثَنَا وَقَالَ، ابْنُ جَعْفَرٍ أَخْبَرَنَا إِبْرَاهِيمُ، - يَعْنِيَانِ ابْنَ سَعْدٍ - عَنِ ابْنِ شِهَابٍ، عَنْ عُبَيْدِ اللَّهِ بْنِ عَبْدِ، اللَّهِ عَنِ ابْنِ عَبَّاسٍ، قَالَ كَانَ أَهْلُ الْكِتَابِ يَسْدُلُونَ أَشْعَارَهُمْ وَكَانَ الْمُشْرِكُونَ يَفْرُقُونَ رُءُوسَهُمْ وَكَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم يُحِبُّ مُوَافَقَةَ أَهْلِ الْكِتَابِ فِيمَا لَمْ يُؤْمَرْ بِهِ فَسَدَلَ رَسُولُ اللَّهِ صلى الله عليه وسلم نَاصِيَتَهُ ثُمَّ فَرَقَ بَعْدُ ‏.‏

sunnah.com