The People of the Book used to let their hair hang down, while the polytheists used to part their hair. The Messenger of Allah ﷺ liked to conform to the People of the Book in matters concerning which he had received no command, so the Messenger of Allah ﷺ let his forelock hang down. Later, he parted his hair.
حدثنا موسى بن إسمعيل حدثنا إبراهيم بن سعد أخبرني ابن شهاب عن عبيد الله بن عبد الله بن عتبة
كان أهل الكتاب يعني يسدلون أشعارهم وكان المشركون يفرقون رءوسهم وكان رسول الله ﷺ تعجبه موافقة أهل الكتاب فيما لم يؤمر به فسدل رسول الله ﷺ ناصيته ثم فرق بعد
Sourced from Bukhari, Clothing, Chapter on the Parting, no. 5917, and Muslim, Virtues, Chapter on the Description of His Hair, His Features, and His Adornment, no. 2336, from the hadith of Ibrahim bin Saad through the same chain.