If your dog is slowly turning your garden into a cratered moonscape then try not to despair because dogs that dig are only doing what comes naturally.
The first step you should take is to try to identify the reason why he is digging. Dogs may dig because of a predatory instinct or they may be digging to bury bones or toys. This is instinctual behavior designed to hide food from other predators.
Digging may also be part of a nesting instinct, particularly if your dog is pregnant. They will also dig a hole if it is too hot because digging exposes cool earth and provides a small shaded, shelter. If your dog is digging under a fence or next to a gate he may simply be trying to get out of the garden. Some dogs dig to alleviate boredom or just for fun. Others may have a genetic predisposition to dig, Terriers for example, are notorious diggers.
What can you do?
Once you've identified why your dog is digging it becomes simpler to correct. All you will need is a little patience and persistence. If your dog is digging in order to chase wildlife you need to find a way to keep them apart, perhaps you could construct some kind of shield or obstacle so he won't be able to see the other animals - after all, if he can't see them, he won't be as tempted to chase them.
If the wildlife is on his side of the fence, then chances are, he won't be fast enough to catch it anyway - squirrels and birds are usually far too speedy for the average dog.
Rats and mice will normally show a dog a clean pair of heels too. Take care if you use poison to deal with vermin such as this, as it could affect your dog as well. Additionally, if you use traps to catch vermin, make sure to keep your dog away from them so he doesn't get harmed.
If your dog simply seems to be trying to get rid of lots of pent up energy you should try giving him more exercise. Take longer or more frequent walks and try to schedule some 'playtime' involving games like fetch that will tire out your dog
Never punish your dog for digging a hole. Even if you bring your dog to the dig site he won't be able to associate his digging with the punishment. If you catch him in the act, direct him to another activity and reward him for choosing to do this new activity instead.