"hair of the dog"?

What’s the origin of the phrase “hair of the dog?” What does it mean? I hear it thrown around from time to time, sometimes as “hair of the dog that bit you.”

Does it have something to do with getting drunk?

How can I avoid a holiday hangover?

From Etymology Online Dictionary:

Phrase hair of the dog that bit you (1546), homeopathic remedy, is in Pliny.

This is the idea that a little bit of the thing that hurt you may help you.