Take an empty bottle with a narrow neck, like a wine bottle, and roll up a piece of paper to make a funnel with a narrow opening at one end. Put a small amount of juice or wine or other fruity liquid in the bottle, then insert the narrow end of the funnel into the neck of the bottle. You now have an instant fruit fly trap! They can go down into the bottle, but can't get back out. That will get rid of the ones you have. Maybe you could release them outside by removing the funnel-I've never tried to release them, and many drown in the liquid.
As far as keeping them away goes, I have no suggestions. I have heard that fruit flies smell the fruit you have in your home and come in through little, tiny cracks and crevices that are normal in any home. I've not heard of a way to keep your home free of them long term, though getting the ones that are already there out of your home will go a long way toward resolving your problem because then those won't be breeding in your home.
You could try a breathable cover for the banannas?
Maybe like a cloth over a fruit bowl?
I am battling my own fly issues here its so gross.
I left the front door open during the last heatwave...
and its grossing me out now! They went directly for my diaper pail,
I guess the water got splashed even though I keep the lid on..