All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
There is nothing wrong with having long hair per se. The Prophet used to let his hair grow long. Just letting the hair grow long is not an imitation of women, and what is commonly done by both men and women is not considered imitation. Scholars underlined that the criterion that determines whether a behavior is considered forbidden imitation of women is when that behavior is specific to women alone. Styling the hair and wearing it in a bun is specific to women, and, therefore, it is impermissible for a man to imitate women in this regard; otherwise, he would be cursed.
If the way you wear your hair constitutes imitation of women, then it is definitely incumbent on you to obey your parents in this regard and wear your hair in any other way that does not constitute imitation of women. Refraining from imitating women is an obligation according to the Sharee‘ah, and the obligation is further emphasized due to the command of the parents. However, if the way you wear your hair does not constitute imitating women, and your parents have no reason for commanding you to cut it, and no harm is feared were you to leave it as it is, then it is not incumbent on you to obey them in this regard.
Please, refer to Fatwa 84942 to know the criterion governing the obligation to obey the parents.
However, it is better to obey your parents and earn their satisfaction in any case since it is one of the greatest good deeds by means of which one draws closer to Allah, and it is one of the best acts of obedience to Allah, The Exalted, to earn His love and pleasure. At-Tirmithi reported that the Prophet said: “The pleasure of Allah is in the pleasure of the parents.”
Allah Knows best.