目前不少项目都是经过 Git 进行管理的,Git 每次提交代码的过程当中 提交说明 commit message 是必须的。但仅仅必须是不够的,好的提交说明能够帮助咱们提升项目的总体质量。git
提交说明最首要的目的是帮助 提交者 说明本次提交的目的,而规范的说明信息有几个好处。github
git commit
上增长 -m <msg>
或者 --message=<msg>
参数,而须要单独写提交信息好的提交说明要包含下面的内容:shell
Angular 主要有三个格式,其中 Head 是必须的,body 和 footer 是可选的。app
# head: <type>(<scope>): <subject> # - type: feat, fix, docs, style, refactor, test, chore # - scope: can be empty (eg. if the change is a global or difficult to assign to a single component) # - subject: start with verb (such as 'change'), 50-character line # # body: 72-character wrapped. This should answer: # * Why was this change necessary? # * How does it address the problem? # * Are there any side effects? # # footer: # - Include a link to the ticket, if any. # - BREAKING CHANGE #
其中 type 用来讲明 commit 的类别,只容许使用下面的 7 个标识。ide
若是 type 为 feat 和 fix ,则该 commit 信息将确定出如今 change log 之中。工具
scope 用于说明 commit 影响的范围,好比影响哪一层、哪一个包中的内容或者使用哪些方案的实例。性能
subject 是关于 commit 信息的简短描述,不超过 50 个字。测试
Body 部分是针对本次 commit 的详细描述,能够多行,要表达清楚变更的动机、与以前行为的对比。this
用于不兼容变更和关闭 Issue 。spa
虽然纯文字的提交说明已经很是明确了,可是却比较单调,并且在一些内容上感受少了一些步骤,因而在现有的内容上进行少许的修改以更美观的清晰。
type 主要将原来的 chore 进行了拆分,增长了 ci 和 review 两个内容,用来补充项目开发过程当中的流程。其它的还有一些内容,能够参照 gitemoji 。
:sparkles:
✨:bug:
🐛:memo:
📝:art:
🎨:recycle:
♻:white_check_mark:
✅:construction_Worker:
👷:ok_hand:
👌:zap:
⚡使用 git log 查询的时候,看到的内容比较简单,能够经过下面的命令将信息格式化输出。
alias lg="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(red)%h%C(r) —— %C(bold blue)%an%C(r): %C(white)%s%C(r) %C(dim white) %C(bold green)(%ar)%C(r) %C(bold yellow)%d%C(r)' --all"
使用命名查询的效果以下: