Skip to content

Instantly share code, notes, and snippets.

@dixudx
Last active April 19, 2021 09:31
Show Gist options
  • Save dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa to your computer and use it in GitHub Desktop.
Save dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa to your computer and use it in GitHub Desktop.
automatically sign-off new commits
#!/bin/sh
# usage:
# run command
# $ cd your-repo
# $ curl -Ls https://gist.githubusercontent.com/dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa/raw/prepare-commit-msg -o .git/hooks/prepare-commit-msg
# $ chmod +x .git/hooks/prepare-commit-msg
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