来自 AngularJS 所用的规范,格式如下:
<type>(<scope>): <subject>
<body>
<footer>
各段内容说明:
标准化的 Git Commit Message 可以用工具过滤出 feat 和 fix 的 Commit 生成 ChangeLog,例如:
git log --format='%s (%h)' --reverse --grep '^\(feat\|fix\)' --since=2020-01-01 --before=2020-02-01 | sed 's/([^)]*):/:/' | sort -k1,1 -s
可以添加到 ~/.gitconfig
里:
[alias]
change-of-last-month = !sh -c 'git log --format=\"%s (%h)\" --reverse --grep \"^\\(docs\\|feat\\|fix\\|perf\\|refactor\\|test\\)\" --since=`date -v-1m +\"%Y-%m-01\"` --before=`date +\"%Y-%m-01\"` | sed \"s/([^)]*):/:/\" | sort -k1,1 -s'
之后用 git change-of-last-month
就可以输出上个月的 ChangeLog。
比如这是我的模板,权作 Commit 时的提醒:
# feat/fix/docs/refactor/perf/test/style/revert/chore(scope/issue): changelog
# Modify issues if necessary
# Details if any
#
开头的行会被作为注释过滤掉。
git config --global commit.template path/to/template
也可以在 ~/.gitconfig
中手动添加
[commit]
template = path/to/template
之后提交时,使用 git commit
不带 -m
参数,就可以调出模板。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.