There is a special tool for that. Failing having that. Do this unless someone has a better idea. It worked well for me a few times.
Measure the location of the gear on the crankshaft against the case or whatever. There is no stop and it needs to go back in the same place.
I used a couple of small pieces of wood to pry against and two screwdrivers to carefully pry up and lift the gear off. DON'T pry in the threads as the gears are fragile and can be split open. I did that once. Swore quite a bit too.
The gear looks the same inside as it does outside so there are some very thin areas.
Tap it back on with a socket or something like that. It doesn't matter which way the gear goes back on as it is symmetrical.