1

I occasionally write Git commits for a project that requires all commits to carry a Signed-off-by trailer, to signal compliance with the Developer Certificate of Origin.

I frequently forget to add this trailer with C-c C-s when writing the commit message using git-commit-mode. I am confident that it will be appropriate to sign-off all the commits I write for this project. Can I have the trailer added by default?

1 Answer 1

1

If you are a Magit user, add the following to your init file:

(defun maybe-git-commit-signoff ()
  "Potentially add a Signed-off-by trailer.

Run \"git config set --local emacs.signOff true\" in a repository if you are
sure it will always be appropriate to sign-off commits to it by default."
  (when (magit-git-config-p "emacs.signOff")
    (apply 'git-commit-signoff (git-commit-get-ident "Signed-off-by"))))

(add-hook 'git-commit-setup-hook 'maybe-git-commit-signoff)

Then, in each Git repository that you are confident that you really want to sign off all commits by default, run:

git config set --local emacs.signOff true

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.