Re: git should not use a default user.email config value
- From
Aaron Schrab <aaron@schrab.com>
- Date
- Aug 11, 2013, 00:06 UTC
- Message-ID
- <20130811000654.GA23413@pug.qqx.org>
- In-Reply-To
- <52060EF9.2040504@alum.mit.edu>
At 11:59 +0200 10 Aug 2013, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 7 quoted lines
>I intentionally don't set user.email in my ~/.gitconfig because I use >different identities (on the same machine) depending on what project I >am committing to (open-source vs. work). After I clone a repo, I *rely* >on Git reminding me to set user.email on my first commit, because I >invariably forget to set it myself. And for me, *any* universal, >heuristically-determined email address would be wrong for me for at >least some repos.
I was in a similar situation for awhile. Except in my case I had $EMAIL set for other reasons, so I didn't get the reminder even if git wasn't configured.
The solution I came up with was to use a template directory to have the following script installed as a pre-commit hook in all new repos:
#!/bin/sh git config user.email > /dev/null && exit echo 'Set email address with `git config user.email` first' >&2 exit 1