In the initial part of the battle, Ghirahim will simply walk towards you. He comes with one hand raised upward, glowing red. The purpose of this is to grab your sword when you slice at him. If he DOES grab your sword, do a down-up vertical slice, or he’ll steal the sword. During this time, he also can slap you if you take too long to hit. How do you hit him? Well, you need to lead his hand in one way, then quickly swing in a different way.
During this time, if he does manage to steal away your sword, you have two options. You can run around until he throws your sword at you, at which point you can grab it, or you can shield bash him during a slice.
Continue attacking for a while, after which this will change a bit. In the second half of the battle, Ghirahim will use his sword and will use three attacks. One involves teleporting and slashing at you (kind of like Sephiroth in Kingdom Hearts). Another involves a running tackle-slash combo, and another has Ghirahim launching five red projectiles at you.
For the first attack, just jump around, preferably backwards (because he’ll appear from behind, and his position is apparently determined upon actually teleporting). For the second, shield bash Ghirahim to stun him and get a few hits in, or swing at him on the side his sword isn’t on. For the third, dodge to the side or move your sword in a slash that would reflect as many projectiles as possible.