The Messenger of Allah ﷺ used to let his hair fall loose over his forehead. The polytheists used to part their hair, while the People of the Book let theirs hang loose. The Messenger of Allah ﷺ liked to conform to the People of the Book in matters about which he had received no specific command. Later, the Messenger of Allah ﷺ parted his hair.
أن رسول الله ﷺ كان يسدل شعره وكان المشركون يفرقون رؤوسهم، وكان أهل الكتاب يسدلون رؤوسهم، وكان رسول الله ﷺ يحب موافقة أهل الكتاب فيما لم يؤمر فيه بشيء، ثم فرق رسول الله ﷺ رأسه.
Bukhari narrated it in the Book of Virtues (3558) and in the Virtues of the Ansar (3944), and Muslim narrated it in the Book of Merits (90:2336), both of them through Ibn Shihab, who said, Ubaydullah bin Abdullah told me, on the authority of Ibn Abbas, who said, then he mentioned it.His statement, "Then the Messenger of Allah ﷺ parted his hair," means through revelation. Parting the hair is recommended according to the majority of scholars.