Skip to content

Commit 245af3f

Browse files
authored
Merge pull request 521xueweihan#25 from ming995/master
增加Git Commit 提交指南
2 parents db6f19b + bd0018f commit 245af3f

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# osx
2+
.DS_Store
3+
4+
# vscode
5+
.vscode

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Git是一个 “分布式版本管理工具”,简单的理解版本管理工
9292
* [把暂存区的指定 file 放到工作区中](#把暂存区的指定-file-放到工作区中)
9393
* [强制推送](#强制推送)
9494
* [一图详解](#一图详解)
95+
* [优雅的提交Commit信息](#优雅的提交Commit信息)
9596
* [联系我](#联系我)
9697

9798
## 展示帮助信息
@@ -640,7 +641,47 @@ git push -f <remote-name> <branch-name>
640641

641642
## 一图详解
642643

643-
![](git.png)
644+
![](./assets/git.png)
645+
646+
## 优雅的提交Commit信息
647+
648+
使用[Angular团队提交规范](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
649+
650+
主要有以下组成
651+
652+
* 标题行: 必填, 描述主要修改类型和内容
653+
* 主题内容: 描述为什么修改, 做了什么样的修改, 以及开发的思路等等
654+
* 页脚注释: 放 Breaking Changes 或 Closed Issues
655+
656+
常用的修改项
657+
658+
* type: commit 的类型
659+
* feat: 新特性
660+
* fix: 修改问题
661+
* refactor: 代码重构
662+
* docs: 文档修改
663+
* style: 代码格式修改, 注意不是 css 修改
664+
* test: 测试用例修改
665+
* chore: 其他修改, 比如构建流程, 依赖管理.
666+
* scope: commit 影响的范围, 比如: route, component, utils, build...
667+
* subject: commit 的概述
668+
* body: commit 具体修改内容, 可以分为多行
669+
* footer: 一些备注, 通常是 BREAKING CHANGE 或修复的 bug 的链接.
670+
671+
### 使用`Commitizen`代替 git commit
672+
673+
可以使用[cz-cli](https://github.com/commitizen/cz-cli)工具代替 `git commit`
674+
675+
全局安装
676+
677+
```shell
678+
npm install -g commitizen cz-conventional-changelog
679+
680+
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
681+
```
682+
全局安装后使用 `git cz` 代替 `git commit`就可以了,如下图
683+
684+
![](./assets/gitcz.png)
644685

645686
## 联系我
646687
- 博客园:[削微寒](http://www.cnblogs.com/xueweihan/)

git.png renamed to assets/git.png

File renamed without changes.

assets/gitcz.png

49.2 KB
Loading

0 commit comments

Comments
 (0)