|
| 1 | +# Write Good Commit Message |
| 2 | + |
| 3 | +写出好的提交信息有助于提高代码可维护性。提交信息包含三个部分:标题(Subject),主体(Body)和相关 Issue。各个部分之间用空行隔开。参考了[write good git commit meesage](https://juffalow.com/other/write-good-git-commit-message). |
| 4 | + |
| 5 | +## 提交信息建议 |
| 6 | + |
| 7 | +### 标题 |
| 8 | + |
| 9 | +好的标题应该回答这个问题: 如果生效,这个提交(commit)"" |
| 10 | +在空的地方应该填入动词加名词的一个简单句子。不超过 50 个字母。 |
| 11 | + |
| 12 | +好的例子: |
| 13 | + |
| 14 | +- 如果生效,这个提交(commit)“删除多余的文件” |
| 15 | +- 如果生效,这个提交(commit)“可以选择多个用户地址” |
| 16 | +- 如果生效,这个提交(commit)"fix bug when network is disconnected" |
| 17 | + |
| 18 | +不好的例子 |
| 19 | + |
| 20 | +- 如果生效,这个提交(commit)“fix bug" |
| 21 | +- 如果生效,这个提交(commit)"user group" |
| 22 | + |
| 23 | +建议标题的尽可能用英文,可以参考如下类别: |
| 24 | + |
| 25 | +- Add = Create a capability e.g. feature, test, dependency. |
| 26 | +- Cut = Remove a capability e.g. feature, test, dependency. |
| 27 | +- Fix = Fix an issue e.g. bug, typo, accident, misstatement. |
| 28 | +- Bump = Increase the version of something e.g. dependency. |
| 29 | +- Make = Change the build process, or tooling, or infra. |
| 30 | +- Start = Begin doing something; e.g. create a feature flag. |
| 31 | +- Stop = End doing something; e.g. remove a feature flag. |
| 32 | +- Refactor = A code change that MUST be just a refactoring. |
| 33 | +- Reformat = Refactor of formatting, e.g. omit whitespace. |
| 34 | +- Optimize = Refactor of performance, e.g. speed up code. |
| 35 | +- Document = Refactor of documentation, e.g. help files. |
| 36 | + |
| 37 | +### 主体 |
| 38 | + |
| 39 | +描述为什么做这个提交以及代码完成了哪些具体功能和做了哪些改动。主体包含多行, 行长度不要超过 72 个字符。 |
| 40 | + |
| 41 | +### Issue |
| 42 | + |
| 43 | +列出相关的 Issue Number。 |
| 44 | + |
| 45 | +## 例子 |
| 46 | + |
| 47 | +```txt |
| 48 | +Fix error when protocol is missing |
| 49 | +
|
| 50 | +First, it checks if the protocol is set. If not, it changes the url and |
| 51 | +add the basic http protocol on the beginning. |
| 52 | +Second, it does a "preflight" request and follows all redirects and |
| 53 | +returns the last URL. The process then continues with this URL. |
| 54 | +
|
| 55 | +Resolves: #56, #78 |
| 56 | +See also: #12, #34 |
| 57 | +``` |
0 commit comments