In my git workflow I use git-commit-notifier to email beautiful, color-coded, diff emails out to the dev group anytime there’s a commit. Problem is, if a new engineer didn’t set his git author email properly that email will get silently rejected from the email group.

I finally got around to creating a git commit hook to reject the commit from the start, and inform the developer to update his or her git author email.

To use, simply create a pre-receive file in your remote repos hooks folder and make it executable.
I wrote this in Node so you’ll need to have Node installed on your server if it’s not there already:

#! /bin/env node
var fs = require('fs'),
arguments = fs.readFileSync('/dev/stdin').toString().split(' ');
exec = require('child_process').exec;
var email = '';
exec('git log -1 ' + arguments[1] + ' --format=%ae', function(err, stdout, stderr){
    if (stdout !== '' && stdout.indexOf(email) == -1){
            console.log('Author email must contain ' + email + '! Your email is currently set to: ' + stdout);
            console.log('Please update by running: git config --global "name@' + email + '"');
            console.log('And then: git commit --amend --reset-author');