The Messenger of Allah ﷺ used to let his hair hang down loose, while the polytheists used to part their hair. The Messenger of Allah ﷺ liked to align with the People of the Book in matters about which he had not been given any specific instruction. Later, the Messenger of Allah ﷺ began parting his hair.
أخبرنا محمد بن سلمة قال حدثنا ابن وهب عن يونس عن الزهري عن عبيد الله بن عبد الله
أن رسول الله ﷺ كان يسدل شعره وكان المشركون يفرقون شعورهم وكان رسول الله ﷺ يحب موافقة أهل الكتاب فيما لم يؤمر فيه بشيء ثم فرق رسول الله ﷺ بعد ذلك
Reported by Bukhari, in the Book of Virtues, Chapter on the Description of the Prophet, hadith no. 3558, from the hadith of Ibn Wahb, and Muslim, in the Book of Virtues, Chapter on the Description of His Hair, His Attributes, and His Nature, hadith no. 2336, from the hadith of Zuhri, with the same wording.