>>2055839You can hang flypaper and it will catch the dumbest ones. If you wanna get thrifty and feel like a master of bug genocide then get some skewers and fold some bright yellow cardstock around it before taping it to the skewer to make a small sign. Slather a thin layer of scentless petroleum jelly or apply two-sided tape or some other sticky substance to the sign and stick it in the dirt of the pot or just set it up close to the place where you see the gnats resting. This will greatly thin the herd.
As for removal of the gnats, it depends on what kind you've got. I'm assuming fungus gnats, and all you have to do with them is let the soil dry out completely and then water it with mosquito-treated water. You can buy mosquito dunks at any hardware or farm supplies store, they're little rings that you're supposed to drop into standing water and they contain bacteria that literally eat insect larvae alive. Mosquito bits might work better for long-term plants; they're basically bits and pieces of the dunks that you can scatter on topsoil so that every watering delivers a batch of zyklon-bug to your plant chambers.
As for prevention, don't overwater your plants and maybe try placing a layer sand on top of your topsoil in order to stop fungus gnats from even penetrating your soil to begin with.