Automating the commit trailer
Part 1. Git client configuration (global):
$ git config --global trailer.consent.key "Author-Rebase-Consent: "
$ git config --global trailer.consent.cmd 'echo "https://No-rebase.github.io" && : '
$ git config --global trailer.consent.ifExists "replace"
        
Part 2. Per-repository commit message hook:
cat >> .git/hooks/commit-msg <<-"EOF"
    #!/bin/sh
    git interpret-trailers --trim-empty --trailer "consent:no" "$1" > "$1.new"
    mv "$1.new" "$1"
EOF
chmod +x .git/hooks/commit-msg
        
Part 2b. Commit message hook improved:

It is possible to automatically add the commit_msg hook to every cloned repo, using a repo template. See the "TEMPLATE DIRECTORY" section of git-init, and the 'init.templateDir' config variable.

Explanation:

  • The git client configuration defines the trailer. It does not cause git to insert it.
  • The commit message hook is the magic that appends the trailer whenever a commit is made.

Also see the interpret-trailers man page.

Friends don't let friends git and rebase