I've done this on my Red version and finished my PokeDex with all 151 Pokemon without having to trade over even a single Pokemon from a different game. I don't know if this is old and everyone knows it but for those of you who don't YOU HAVE MY WORD THIS IS LEGIT. It didn't mess up my game at all.
The trick is the last Pokemon you fought has to have the right special number for whatever Pokemon you want to appear. An easy way to do that is to fight the trainer then go find a wild Ditto like east of Fuchsia City, let it transform into your Pokemon with the special attack you need, then knock it out. When you do the glitch it'll be the Pokemon you planned for.
If you guys like this I'll post all the special numbers for all 151 Pokemon so you can get all the others, not just Mew.