How to Keep Dogs Out of Gardens
One of the easiest ways to keep dogs out of gardens is by putting up a fence or plant barrier that they can't cross. You can also try spreading gravel or mulch around the area, since dogs dislike the sensation of those materials on their paws. Pungent odors like white vinegar or apple bitter are known to repel dogs, so you can try spraying your garden plants with those. Don't worry, the stinky liquids are perfectly safe for vegetables and plants!
Put up a fence. Perhaps the most obvious way to keep dogs out of your garden is to put up a fence. You can pay to have a fence installed professionally (which can be expensive), or consider erecting one yourself. You may choose a fence made from wood, wire, or mesh, which can all be found at your local home repair store. For small dogs, a 16” fence should be adequate. For large dogs, you may need a taller fence or a fence with a top-enclosure. Use plant barriers. If you don't find a traditional fence aesthetically pleasing, you can use plants to form a barrier around your garden. Tall, sturdy plants or shrubs are your best bet for this purpose. Although thorny or prickly plants can deter dogs, they may also cause some injury. You might consider: Tall sturdy plants, such as peony, cone flower, verbena, Russian sage, Mexican primrose, and black-eyed Susans. Shrubs, like evergreen, laurel, escallonia, and huckleberry. Try planting a barrier of marigolds. Dogs don't like the smell of marigolds, so your garden will be less inviting to them. Create a barrier using gravel or mulch. Dogs dislike the texture of gravel and mulch against their paws. So, another option is to create a mote-like barrier around your garden using these substances. Mulch is available at most hardware stores. Mulches made from pinecones or needles are good options. You do not want “dog-friendly” mulch for this purpose! Gravel is available at many hardware stores and greenhouses. Select rocks with rough edges to best deter dogs. Spray vinegar or apple bitter on vegetables. Pungent odors like white vinegar or apple bitter have been shown to repel dogs and other creatures, but these stinky liquids are perfectly safe for vegetables and plants. Fill a spray bottle with white vinegar or apple bitter and give your garden a spray after watering. White vinegar is available at most grocery stores. Apple bitter is available at most pet stores. Sprinkle some spices. Strong smelling herbs and spices are unattractive to dogs. You can keep dogs out of your garden by sprinkling spices around the perimeter. Place 1 tsp of powdered spices for every square foot of your garden. Repeat after heavy watering or rain. Try mustard powder, red pepper flakes, or a mixture of both. Avoid cayenne pepper, as this can injure a dog's sensitive feet. Experiment with any spices (excluding cayenne) that you have at home. Spices can be purchased at most grocery stores. Place potatoes or orange peels around the garden. Certain food items—such as semi-rotten potatoes and orange peels—are repulsive to dogs. By placing these foods around your garden, you can effectively deter dogs from entering the space. Use the peal of one orange and/or one semi-rotten potato for every 2 square feet of your garden. Replace these when have visible rotted away. Shred orange peels into chunks or slices, and sprinkle these around your garden. Leave potatoes in your pantry for approximately three weeks, then place whole potatoes around your garden. Install a motion-activated sprinkler. Motion-activated sprinklers can be programmed to spray water anytime an animal enters the garden. These sprinklers can deter not just dogs, but cats, deer, and other unwanted animal intruders. Motion activated sprinklers range from $35 to over $100. A popular choice is the “Orbit 62100 Yard Enforcer Motion Activated Sprinkler,” available on Amazon for $60. Build a dog path. If your dog frequently walks on your garden on its way someplace else, you may be able to provide a better path for it! If you are open to reorganizing your garden, you can create a path right through the middle. Otherwise, create a path for your dog nearby. For a pleasant dog-friendly path, you may want to use: Soil/sand mixture. Outdoor carpet. Step stones. Create a dog-friendly space. You can encourage your dogs to stay away from the garden by providing a better space for them to play. If you like having the dogs with you in the yard, this is great way to keep them happy and enjoy their company. Choose a location. Dogs tend to prefer shade. Provide enough space for dogs to play and relax. Select a dog-friendly surface. The top choice is a sand/soil mixture, but wood chips or leaves will work too. Provide some toys and a dish with water. Use positive reinforcement to encourage dogs to hang out in this space. Train your dog. If the dog in question belongs to you, you may be able to train it not to enter the garden. If your dog has never had any kind of training, you might consider formal obedience training for your pet. Praise your dog when it does not enter the garden and provide a treat. Scold your dog with a firm "No" when it enters the garden. Avoid yelling or physical threats. Be consistent and try to remain patient throughout this process. 
Put up a fence. Use plant barriers. Create a barrier using gravel or mulch. Spray vinegar or apple bitter on vegetables. Sprinkle some spices. Place potatoes or orange peels around the garden. Install a motion-activated sprinkler. Build a dog path. Create a dog-friendly space. Train your dog. 