I came to the Prophet ﷺ with long hair. When the Messenger of Allah ﷺ saw me, he said, "Trouble, trouble."So I went back and cut it. Then I came to him the next day, and he said, "I did not mean you, but this is better."
حدثنا محمد بن العلاء حدثنا معاوية بن هشام وسفيان بن عقبة السوائي هو أخو قبيصة وحميد بن خوار عن سفيان الثوري عن عاصم بن كليب عن أبيه
أتيت النبي ﷺ ولي شعر طويل فلما رآني رسول الله ﷺ قال ذباب ذباب قال فرجعت فجززته ثم أتيته من الغد فقال إني لم أعنك وهذا أحسن
[Its isnad is sahih] Ibn Majah narrated it in Libas, chapter on the disapproval of excessive hair, no. 3636, and Nasai, no. 5055, from the hadith of Muawiya and Sufyan bin Uqbah, through him. Sufyan Thawri explicitly stated that he heard it directly, as recorded by Nasai.