Put her in her room. Pick her up and take her there and close the door. She cannot come out until she is not yelling or crying anymore. When she calms down, THEN you open the door and say "Are you done? Are you ready to keep your hands to yourself?" Then let her out of her room. Repeat this every single time. You must be 100% consistent or she will NOT get the lesson at all.
She doesn't understand this. She really doesn't. But what you are teaching her is that there are unpleasant consequences for her unpleasant behavior. Eventually when her brain is more developed, it will make sense, and separating her from you, not allowing her to have attention for her hitting you, will finally click in her brain and she will stop doing it. (Btw, negative attention is still attention.)
The next thing you must do is get her help with learning to communicate. She is 2 1/2 now and should be doing a lot more talking. One of the reasons she hits is because she is frustrated with her lack of abililty to make herself understood. Call your ped and ask for a referral to a speech therapist for an evaluation. You need to get her some help. I really mean that. Your ped should have talked to you at her 2 year well visit about her ability to communicate.
Don't take no for an answer from your ped. Don't agree to wait until she is 3. You need to get her some help now. Meanwhile, try to help her get across to you what her needs are. Ask her questions. Ask her to point. "Do you want some water? Say wah-wah. (she tries) Good job saying wah-wah! Here's some wah-wah.".
The last thing I want to say, is when she goes to hit you, grab her hands and hold on to them VERY firmly, and don't let go. She won't like it, but you should do it anyway. Say to her "hands are for helping, not hurting. We don't hit." When you think you've got your point across, then let go. If she hits you again, she's in her room.
Good luck,
Dawn