Cats, whether they are feral, stray or your neighbor's pet, pay little heed to fences and property lines. There are several different ways to keep cats out of your yard while not harming your dog. You can keep cats out while not harming them by using a repellent to deter them.
Set up a motion-activated sprinkler. This is an effective deterrent and is not harmful to your dog or the yard. Motion-activated sprinklers use infrared to detect when an animal enters a defined territory. When a cat enters your yard, the sprinkler shoots outs a burst of water in its direction, typically scaring the cat rather than soaking it. Use the sprinkler in the summer, as the water will freeze in winter. By the time winter rolls around, the cat will know not to enter that area. Remember to shut it off when letting your dog outside.
Use a scent repellent to deter cats from gardens or fences. A scent repellent works better for smaller areas as it must be replenished after it rains. A scent repellent is a powder or liquid that has an offensive odor to cats, such as citrus. Use a scent repellent that only cats dislike as some may be malodorous to your dog as well.
Create a physical barrier to keep out cats. If the cat has been crawling through a hole in your fence, block it. Make a small, easily removable cage to put around your garden or buy a small fence at a pet store to keep cats away.
Ask neighbors to keep their cats indoors. Not only are they invading your property and possibly destroying your plants, but cats have a much higher life expectancy when they are purely an indoor animal. Catch stray cats and take them to a no-kill shelter.