One way to do this is to offer a trap crop that the pest loves more than your main crop, something you can sacrifice for the greater good. Planting the herb dill near tomatoes is a good example, because tomato hornworms will attack the dill over the tomatoes. You can then pick the hornworms off the dill as they appear. If you’re careful, you may be able to save the dill; but even if you don’t, you’ve kept a nasty critter away from your tomatoes.
Here’s a great Companion Planting Chart from North Carolina State University Extension.
Want to learn more about companion planting?
We’ve got you covered with a lot more information on companion planting for your home garden. Check out these in depth guides to companion planting:
How to Use Companion Planting In Organic Gardens
Almanac.com writes about Dealing with Tomato Hornworms