Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add to ~/.bash_profile to auto-sign git commits.
# Always signs commits for DCO (popularized by The Linux Foundation, required by
# most CNCF projects including Helm).
# See `git help commit`:
# > -s, --signoff
# > Add Signed-off-by line by the committer at the end of the commit log
# message. The meaning of a signoff depends on the project, but it typically
# certifies that committer has the rights to submit this work under the same
# license and agrees to a Developer Certificate of Origin (see
# for more information).
git() {
if [ $# -gt 0 ] && [ "$1" == "commit" ] ; then
command git commit --signoff "$@"
command git "$@"

This comment has been minimized.

Copy link
Owner Author

@scottrigby scottrigby commented Sep 8, 2018

Note we could alternatively do this through a git hook (cat .git/hooks/prepare-commit-msg.sample to see how). That could be made global, but requires re-initing each existing repo as part of that process (see

This gist is a quick and easy solution that just requires a new shell session (bash --login, etc).

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