On my system I don\'t have the user.email
git configuration value set at the global level, on purpose. Instead, I configure it individually in each sandbox. This is
You can use a pre-commit hook to prompt you to setup your project-specfic email address. For example:
#!/bin/sh
email=`git config user.email`
if ["$email" = '']
then
echo "you need to set your email for this project"
exit 1
fi
This will cause committing without the appropriate config to fail:
$ git commit -va
you need to set your email for this project
$
You can use git templates to make sure the hook is present in future repositories by default, by placing the hook in the templates folder:
-> tree /usr/share/git-core/templates/
/usr/share/git-core/templates/
├── branches
├── description
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-rebase.sample
│ └── update.sample
└── info
└── exclude
The exact location of the templates folder may vary with OS/distribution.
For existing repositories - either create/copy the hook into place or if the git-core templates folder has been updated run git init
to create the new hook file.