Toss a smoke bomb or road flare down into the tunnels to drive out the gophers. You can also force them out by dumping water into their tunnels or by encouraging a wild gopher snake or barn owl -- major gopher predators -- to reside near their tunnels. After they've left their tunnels, use a deterrent method to keep them from coming back.
Sprinkle castor oil pellets around your yard, then water the pellets. The pellets don't harm the gophers, they just release an odor that deters away the gophers. Watering the pellets helps release the odor. The castor oil pellets are not harmful to your lawn, as castor oil is a type of vegetable oil.
Trap the gophers. Place an appropriately sized rodent trap at one end of one tunnel. Cover the trap and the tunnel hole with a burlap sack or large trash bag so that no light shines through to give away the position of the trap. Wear gloves while setting up the trap and sprinkle rosemary around the trap to mask your scent. The gopher will run into the trap. Relocate the gopher.
Relocate your gardens into raised wooden beds. If the gophers try to dig underneath the beds, they'll be face-to-face with wooden planks instead of your flowers or vegetables. A raised bed at least 1 foot high and 6 inches deep keeps gophers away, as they won't be able to climb up and over it. If building a new garden is not practical for you, spray rodent repellent on your plants and flowers. The smell deters the gophers from making a meal out of your garden.
Hire an exterminator as a final resort. Exterminators will either humanely trap the gophers or use a fumigant, aluminum phosphide, to kill the gophers, depending on your preferences and the situation. This chemical is safe to use around your pets, and scavengers that eat the gophers will not get sick from it either.