| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Git hook to help you write good commit messages.
Validates commit messages conform to six of the seven rules of a great git commit message, plus a couple of extras:
Offers an interactive prompt if any of the rules are detected to be broken.
At the root of the repository, run:
curl -L https://raw.githubusercontent.com/tommarshall/git-good-commit/v0.7.0/hook.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msgTo use the hook globally, you can use git-init's template directory:
mkdir -p ~/.git-template/hooks
git config --global init.templatedir '~/.git-template'
curl -L https://raw.githubusercontent.com/tommarshall/git-good-commit/v0.7.0/hook.sh > ~/.git-template/hooks/commit-msg && chmod +x ~/.git-template/hooks/commit-msgThe hook will now be present after any git init or git clone. You can safely re-run git init on any existing repositories to add the hook there.
Alternatively, core.hooksPath (Git 2.9+) points every repository at one shared hooks directory, so there's only a single copy to maintain:
mkdir -p ~/.git-hooks
curl -L https://raw.githubusercontent.com/tommarshall/git-good-commit/v0.7.0/hook.sh > ~/.git-hooks/commit-msg && chmod +x ~/.git-hooks/commit-msg
git config --global core.hooksPath ~/.git-hooksUnlike the template approach, this applies to repositories you've already cloned, and updates in one place. Note that core.hooksPath replaces each repository's .git/hooks, so any other hooks — including those installed by tools like Husky, pre-commit or lefthook — won't run unless you also add them to ~/.git-hooks.
If you're security conscious, you may be reasonably suspicious of curling executable files. In this case you're on HTTPS throughout, and not piping directly to execution, so you can check contents and the hash against MD5 d25310de1598dbc784539dabaf12cd51 for v0.7.0.
echo "apple" > ./bar.txt
git add fruits.txt
# should warn you that the subject line is not capitalised, and offer an interactive prompt.
git commit -m 'add fruits.txt'e - edit commit message y - proceed with commit n - abort commit ? - print help
The default colour setting is auto, but the hook will use git's color.ui config setting if defined. You override the colour setting for the hook with:
git config --global hooks.goodcommit.color "never"
Supported values are always, auto, never and false.
None, other than Bash.
| Back | FazBrowse Home | New Git URL |