To humanely remove groundhogs from a yard or garden, frighten them away with sound or motion devices, or repel them with certain odors or tastes. Also, fence them out, or live-trap them when they exit their burrow. Groundhogs can then be relocated far from the premises.
Groundhogs are timid creatures who are frightened by motion, so install pinwheels or other moving objects in various places around the yard or garden. Bells or windchimes may also keep them away. As prevention, keep grass and weeds short, and do not allow brush piles to remain; without sufficient cover, groundhogs may not take up residence in the first place.
Groundhogs do not like the taste of Epsom salts; sprinkle this around the garden to discourage them from eating. They also do not like the smell of ammonia, so strew ammonia-soaked rags around the yard's perimeter to keep them out. Rain washes away Epsom salts, and the smell of ammonia eventually fades, so reapplication is necessary.
Install fencing that is at least 4 feet high. This prevents groundhogs from climbing over it. Bury underground fencing to a depth of 1-foot, and bend 90 degrees to prevent tunneling.
To live-trap, bait a box with a tripping mechanism, and relocate the animal at least five miles away. Relocate the groundhog as soon as possible, and keep the trap in the shade. Check with state laws if relocating to public land, or a landowner if private land.