The preliminary solutions proposed here work well, and I agree with one of them. I ended up using this:
if [ -z $(git config user.email) ]; then echo "You need to set your user.email configuration value for this project" echo "git config user.email foo@example.com" exit 1 fi
It is activated system-wide in my ~/.gitconfig with the init.templatedir configuration init.templatedir , which I saw in another Stack Overflow post. I put my dir template on github as part of my git-tools .
In addition, I realized that I can just check on my command prompt prompt, which already adds git status to the prompt, to print a large, bold warning when I burn a CD to a sandbox that does not have user.email configured.
In my .bashrc :
PS1='\u@\h:\W$(parse_git_branch) \$ ' parse_git_branch() { local DIRTY STATUS EMAIL_NOT_CONFIGURED_WARNING STATUS=$(git status 2>/dev/null) [ $? -eq 128 -o $? -eq 127 ] && return [ -z $(git config user.email) ] && EMAIL_NOT_CONFIGURED_WARNING=$' \x1b[31m(user.email not configured)\x1b[m' [[ "$STATUS" == *'working directory clean'* ]] || DIRTY=' *' echo "($(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* //')$DIRTY)$EMAIL_NOT_CONFIGURED_WARNING" }
This gives an easily visible warning:

Marc liyanage
source share