Some developers swear by a beer / scotch / wine or two when working through a trialling project, but tipsy only takes you so far. To avoid any embarrassing commits (or commit messages), you can grab yourself an Arduino and a script called "gitdown" to act as a sobriety gatekeeper for your repository.
Developed for 2013's HackNY (at which it won first place), "gitdown" is the brainchild of coders Geoffrey Litt and Alex Qin. It uses an Arduino-powered breathalyser called "DrinkShield" to stop you from committing code while too drunk.
Specifically, it checks your blood-alcohol level against a pre-configured limit:
Normal mode: Only lets you commit with a BAC of less than 0.05%. Krunk mode: Only lets you commit with a BAC of greater than 0.05%. Ball(m)er mode: Only lets you commit with a BAC of between 0.13% and 0.15%.
It'll even "mangle" your commit messages (see above) and it's hooked up to a public Tumblr account, so everyone can witness your inebriated programming shame. That said, the last entry is from two years ago; I'd be surprised (and concerned) if there were any regular users of gitdown.