Skip to content
项目

tommarshall/git-good-commit has 202 GitHub stars and 35 forks. Star changes are not measured yet. Last checked 2026-11-13 23:42 UTC. Last push 2026-08-26.

这些数字如何统计

实测星标增长

24小时
正在收集历史
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

关于

Git hook to help you write good commit messages, with no external dependencies.

开发工具

README.md

原文

git-good-commit

CI

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:

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how - you're on your own with this one
  8. Do no write single worded commits
  9. Do not start the subject line with whitespace

Offers an interactive prompt if any of the rules are detected to be broken.

git-good-commit animated demo

Installation

Single repository

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-msg

Globally

To 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-msg

The 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.

Alternative: a single global hook

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-hooks

Unlike 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.

Usage

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'

Options

e - edit commit message
y - proceed with commit
n - abort commit
? - print help

Configuration

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.

Dependencies

None, other than Bash.

Credits

探索相关项目