-
Set a global githooks directory
$ mkdir -p ~/.git/hooks $ git config --global core.hooksPath "~/.git/hooks"
-
Download the
prepare-commit-msg
file into the directory -
Ensure it is set as executable (Linux and macOS)
$ chmod +x ./prepare-commit-msg
This githook will append the
Co-authored-by
trailers to the commit message.If you want this githook to add a Jira Issue ID as a prefix to the commit message when the git branch name begins with a string resembling one, uncomment line 12 to call the function
add_jira_issue_id_prefix
.
If a repository overrides core.hooksPath
git configuration variable (e.g when using husky), then you will need to do additional steps for each such repository
-
Retrieve the local (repository-specific) hooks directory
$ git config --local core.hooksPath
-
Download the
prepare-commit-msg.local
asprepare-commit-msg
file into the directory -
Ensure it is set as executable (Linux and macOS)
$ chmod +x ./prepare-commit-msg
This githook will invoke the global
prepare-commit-msg
githook that you originally set up.