Skip to content

Instantly share code, notes, and snippets.

@ghostwriter
Created March 7, 2026 00:42
Show Gist options
  • Select an option

  • Save ghostwriter/85d32bace365e625c3db0dce0cbe7e1a to your computer and use it in GitHub Desktop.

Select an option

Save ghostwriter/85d32bace365e625c3db0dce0cbe7e1a to your computer and use it in GitHub Desktop.
Automatically adds a Signed-off-by line to the message.
#!/bin/sh
set -o pipefail
set -o errtrace
set -o nounset
set -o errexit
# Automatically add a Signed-off-by line to the message.
SOB="Signed-off-by: $(git config user.name) <$(git config user.email)>"
grep -qs "^$SOB" "$1" || echo "\n\n$SOB" >> "$1"
@ghostwriter
Copy link
Author

https://git-scm.com/docs/githooks#_commit_msg

Copy the above code and run the following commands at the root of the git repo.

  1. pbpaste > .git/hooks/commit-msg

  2. chmod +x .git/hooks/commit-msg

  3. profit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment