This is a topic that has been much discussed around here. If you type cats
into the Google custom search box above (which only searches THG) you will find many threads.
Here are just a few:
https://www.helpfulgardener.com/forum/vi ... php?t=5155
https://www.helpfulgardener.com/forum/vi ... hp?t=22405
https://www.helpfulgardener.com/forum/vi ... hp?t=11724
https://www.helpfulgardener.com/forum/vi ... hp?t=50491
Since I haven't done it for awhile, I will do a summary of
cayenne pepper, rue, grapefruit or lemon peels scattered around or citrus juice spray,coffee grounds, pipe tobacco, oil of
lavender, lemongrass, citronella, or eucalyptus, or a commercial aromatic spray product, such as Dog and Cat Repellent, available at https://www.gardeners.com
Physical barrier: cats
like to dig in bare soil, so anything that keeps them from walking on the soil (irritates their feet), getting to the soil, or digging in the soil, will keep them from making deposits in it. That includes putting down thorny or spiky things like trimmings from thorn bushes, sweet gum seed balls, pine cones, etc. Or there are plastic mats with little spikes. Or you can lay down chicken wire flat and then cover it with soil, which prevents them from digging. Grow thick ground cover or cover bare ground with river rock. Personally, I find just keeping your soil mulched heavily (which I like to do anyway), keeps them from using it.
Attract them away:
Grow catnip away from your regular garden
or set up a sand box for them to use away from your regular garden
(but you would have to scoop it sometimes).
There are also devices that are a motion sensor hooked up to a sprinkler so they set off the motion sensor and then get sprayed with water. Or you can just guard your garden
with a hose. Shouldn't take very many trials of
that before they learn their lesson.