Another possibility is that Harry initially gets angry. He has been through so much and saved the wizarding world multiple times, so he might feel betrayed. He could lash out at those who reject him, but then gradually realizes that this isn't the way and instead tries to prove his worth through acts of kindness and heroism again, hoping to win back the hearts of those who have turned away from him.
Perhaps Harry tries to find the root cause of the rejection. He might start investigating if there's some sort of dark magic or false rumor spreading about him that has made everyone turn against him. He could question his closest friends or even seek out the help of some of the more reclusive teachers at Hogwarts to figure it out.
One reason could be a misinformation campaign. Some malicious wizard or witch might have spread false rumors about Harry, making everyone believe that he has done something terrible like being in league with Voldemort again.
Harry could try to find out the root cause of the rejection. He might start investigating if there are any external influences on his mates. He could also reach out to other characters for support, like some of the Hogwarts professors. And he might try to prove himself to his mates, by showing them that he's still the same Harry they used to know deep down.
Harry could try to communicate openly with his mates. He can explain his side of the story and clear up any misunderstandings. This might be difficult at first, but it's a direct approach.
He could also give his mate some space for a while. Sometimes, distance can make the heart grow fonder. By giving space, his mate might have time to think about their relationship and realize what they are missing.
He might be initially heartbroken. Harry has always been a bit of an emotional person, so he could go into a state of depression for a while. He might isolate himself from his friends and focus only on his studies or fighting against the dark forces, using it as a way to distract himself from the pain of the rejection.
Harry would probably be deeply hurt. He might pour himself into his studies or his work in the wizarding world. He could also try to distract himself by taking on more dangerous tasks or missions. But ultimately, he'd have to face his feelings towards Ginny and decide whether to forgive her or move on completely.
In some fanfictions, Harry might use his knowledge of magic in unexpected ways. For example, he could combine spells in a new and creative manner that others haven't thought of. This gives him an edge over everyone.
Sometimes, Harry might use the rejection as motivation. He could focus more on his training or other important tasks at hand, like fighting against the Dark forces. He realizes that he has bigger things to worry about than a failed romantic pursuit, and this rejection could fuel his determination to prove himself.
He might go to Madam Pomfrey in the hospital wing. She has all kinds of potions and remedies to help with ailments, so she could easily give him something to soothe his stomach.
He might focus on his studies. In the wizarding world, there are so many interesting magical subjects like Potions, Transfiguration. By burying himself in books and learning new spells, he can at least distract himself from the lack of friends.