Fruit flies are nearly as frustrating as ants and equally impossible to eradicate—but there are a few ways to get rid of them. We've already shown you that apple cider vinegar, dishwashing soap, and plastic wrap is a great way to trap and kill fruit flies, but if you just want to keep them away, there's another option—cloves.
Fruit flies are attracted to ripened fruits and vegetables, but don't actually eat them. They eat the fungus or rot that grows on them, according to Todd Schlenke, assistant professor at Emory University, who specializes in Drosophila (aka fruit flies). So the number one way to keep fruit flies out is to simply make sure your fruit is not over-ripe or rotting.
However, fruit flies can also find their way into drains, garbage disposals, bottles, cans, trashcans, and cleaning tools, where rotting food can still thrive as a thin, moist film of fermenting material, according to Michael F. Potter, a professor of entomology at the University of Kentucky.
While it's nearly impossible to get rid of all traces that a fruit fly is attracted to in your kitchen, it is possible to put something out that overpowers the stench of fermenting material. That's where whole cloves come in, which can be found in any normal grocery store or directly online.
Many people online suggest sticking a single ripe apple (with its skin still on) with whole cloves—about 20 to 30 of them—and place it wherever you think fruit flies will be attracted to. The strong smell of cloves (which fruit flies find disgusting) will keep them away, so they won't enter doorways, windows, or any other openings if cloves are nearby. They can even help fruit flies flee if they're already there. Oranges also work well, too.
However, you don't need any fruit to keep fruit flies away. Just using cloves along should do the trick, since the fruit will eventually rot and possibly overwhelm the pungent cloves smell. If you want to make this apple/cloves combo last longer, you can turn it into a pomander ball, which adds a blend of spices that help cure and preserve the fruit so that it won't mold or spoil.
So the next time your bananas are looking a little brown, eat them or throw out some cloves to keep the fruit flies away. If they're already infested, then you can resort to the apple cider vinegar trap.