The term was coined by Carlin J. Vieri, a Ph.D. at MIT back in the 90s.
Yak shaving is what you are doing when you’re doing some stupid, fiddly little task that bears no obvious relationship to what you’re supposed to be working on, but yet a chain of twelve causal relations links what you’re doing to the original meta-task.
Source: Yak Shaving Defined - I’ll get that done, as soon as I shave this yak.
Example: Hal fixing a light bulb (from Malcolm in the Middle S03E06 - Health Scare)