If I know I'm only going to get a few hours of sleep, I'll take 5–10 g of creatine, drink plenty of water, and go to bed. The next morning, I usually don't wake up with a headache.
If I skip the creatine under the same conditions, I'm much more likely to wake up with a headache after a short night's sleep.
Now it's become a habit, I automatically take creatine whenever I know my sleep duration is going to be much shorter than usual.