Last active
April 10, 2023 17:21
-
-
Save fgaray/c9c5a7e498a57237ff9c456824c1f145 to your computer and use it in GitHub Desktop.
Git Hook: Sign-off your commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# File: .git/hooks/prepare-commit-msg | |
# Source: https://stackoverflow.com/a/46536244 | |
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment