Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

规范你的Git Commit message #1

Open
gaoac opened this issue Apr 6, 2020 · 0 comments
Open

规范你的Git Commit message #1

gaoac opened this issue Apr 6, 2020 · 0 comments

Comments

@gaoac
Copy link
Owner

gaoac commented Apr 6, 2020

写在前面

关于 Git,大家想必都很熟悉,因为我们几乎每天都在重复着git addgit commitgit push等命令,自然也就留下很多“痕迹”,如果没有好的规范和工具来约束,可能就会出现以下情况:

git_commit_error

因此,规范和工具的重要性就体现出来了:

关于 Git Commit message 的写法规社区有多种,本文采用的的 Angular 规范是目前使用最广的写法,比较合理和系统化,并且有配套的工具。

推荐文章

相关工具

安装

由于 commitizen 是基于 nodejs 的工具,所以首先需要安装 node 环境,具体不再赘述。

全局
yarn global add commitizen cz-conventional-emoji
# OR
# npm install --global commitizen cz-conventional-emoji

# 设置全局默认适配器
echo '{ "path": "cz-conventional-emoji" }' > ~/.czrc
本地
yarn add commitizen cz-conventional-emoji
# OR
# npm install --save-dev commitizen cz-conventional-emoji

# 为你的项目设置默认适配器
"config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-emoji"
    },
  }

使用

以后,凡是用到 git commit 命令,一律改为使用 git cz。这时,就会出现选项,用来生成符合格式的 Commit message(commitizen 与 emoji 结合)。如图:

Select the type of change that you're committing: (Use arrow keys)
❯ ✨  Feat:              Introducing new features.
  🐛  Bug:               Fixing a bug.
  📝  Docs:              Writing docs.
  🎨  Style:             Improving structure / format of the code.
  💄  UI:                Updating the UI and style files.
  🚑  Quickfix:          Critical hotfix.
  ⚡️  Pref:               Improving performance.
(Move up and down to reveal more choices)

再看提交记录,是不是赏心悦目多了:

git_commit_normal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant