Now there is a simple way to automatically exit any commit that has not yet been completed using traps and the git-interpret-trailers command. In the next version 2.15, the git command allows you to trivially check for a signature (regardless of its value / author) and add your own, if it is not already there. As of October 2017, the required code is not yet available in any git release (but in its master branch)!
Save the following as .git/hooks/prepare-commit-msg or .git/hooks/commit-msg (see the differences here ) and make it executable.
#!/bin/sh NAME=$(git config user.name) EMAIL=$(git config user.email) if [ -z "$NAME" ]; then echo "empty git config user.name" exit 1 fi if [ -z "$EMAIL" ]; then echo "empty git config user.email" exit 1 fi git interpret-trailers --if-exists doNothing --trailer \ "Signed-off-by: $NAME <$EMAIL>" \ --in-place "$1"
stefanct
source share