DEV Community

Discussion on: What are Git Hooks?

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

pre-commit

#!/bin/sh

# Make sure the email is set properly before committing the file
required="skay@gmail.com"
useremail=$(git config user.email)

# Check if the git config useremail DOES NOT MATCH your required
if [ "$useremail" != "$required" ]; then
        echo "Error: user.email not set to \"$required\"" >&2
        exit 1
fi
Collapse
 
skaytech profile image
skaytech

Great suggestion on the error message to be generic :-)