In addition to wearing protective clothing, an excellent way to prevent gnats from invading your space is by applying a spray made with peppermint essential oil.
With its strong odor, concentrated peppermint essential oil naturally deters gnats, but avoid applying it undiluted as it can be a minor skin irritant.
Instead, add 15-20 drops of peppermint essential oil to a pint of water before adding a tablespoon of vinegar or vodka as a dispersant and decant the mixture into a spray bottle.