Preventative measures should always be taken to protect new crops and vegetable gardens that are placed into a groundhog habitat. Since the groundhog is primarily a surface forager, fencing is the most effective way to keep these animals out, however, diligence must be observed in the selection of a fencing material due to the groundhogs ability to climb over and through them. The fence should be a minimum of three feet in height with hole spacing no greater than 2 inches and the bottom of the fence should be buried 10 to 12 inches into the ground to prevent tunnel-under. If the groundhog appears to successfully scale the fence to gain access, the top of the fence can be bent away from the garden (unsupported - do not make this bent section rigid) or a low voltage electric top wire can be added as a deterrent - available at some hardware and most feed stores (check for legality of this application in your area prior to use).
Underground cabling should always be installed inside conduit or protected in some manner anywhere burrowing animals - gophers, moles, voles, prairie dogs, squirrels, chipmunks, shrews, etc) may be present.
Scarecrows have limited effectiveness unless they are moved frequently. The use of loose clothing or moving objects on the scarecrow may increase its success.