Skip to main content

Commit

  • -a: 跳过暂存阶段(git add)
  • -v: 显示详细 diff 信息
git commit -a -v

重新提交

git commit --amend -a -v

Style Guide

Conventional Commits specification:

pnpm add -D commit-and-tag-version
pnpm dlx commitizen init cz-conventional-changelog --save-dev --save-exact
<type>(<scope>): <subject>
(emptyLine)

<body>
(emptyLine)
<footer>

Subject

No more than 50 characters.

Type

  • feat: 新增了一个功能 (MINOR Version).
  • fix: 修复了一个 bug (PATCH Version).
  • docs: 只是更改文档.
  • style: 不影响代码含义的变化 (空白、格式化、缺少分号等).
  • refactor: 代码重构, 既不修复错误也不添加功能.
  • perf: 改进性能的代码更改.
  • test: 添加确实测试或更正现有的测试.
  • build: 影响构建系统或外部依赖关系的更改 (示例范围: gulp, broccoli, NPM).
  • ci: 更改持续集成文件和脚本 (示例范围: Travis, Circle, BrowserStack, SauceLabs).
  • chore: 其他不修改 src 或 test 文件 e.g. chore(release).
  • revert: commit 回退.

Scope

  • init
  • runner
  • watcher
  • config
  • web-server
  • proxy
  • empty

Body

  • uses the imperative, present tense: “change” not “changed” nor “changes”
  • includes motivation for the change and contrasts with previous behavior
  • referencing issues e.g. close #666, #888
  • BREAKING CHANGE (<type>!) (MAJOR Version) e.g.port-runner command line option has changed to runner-port, so that it is consistent with the configuration file syntax. To migrate your project, change all the commands, where you use --port-runner to --runner-port.

Emoji

Commit typeEmoji
Initial commit🎉 :tada:
Version tag🔖 :bookmark:
New feature :sparkles:
Bugfix🐛 :bug:
Metadata📇 :card_index:
Documentation📚 :books:
Documenting source code💡 :bulb:
Performance🐎 :racehorse:
Cosmetic💄 :lipstick:
Tests🚨 :rotating_light:
Adding a test :white_check_mark:
Make a test pass✔️ :heavy_check_mark:
General update :zap:
Improve format/structure🎨 :art:
Refactor code🔨 :hammer:
Removing code/files🔥 :fire:
Continuous Integration💚 :green_heart:
Security🔒 :lock:
Upgrading dependencies⬆️ :arrow_up:
Downgrading dependencies⬇️ :arrow_down:
Lint:shirt: :shirt:
Translation👽 :alien:
Text:pencil: :pencil:
Critical hotfix🚑 :ambulance:
Deploying stuff🚀 :rocket:
Fixing on MacOS🍎 :apple:
Fixing on Linux🐧 :penguin:
Fixing on Windows🏁 :checkered_flag:
Work in progress🚧 :construction:
Adding CI build system:construction_worker: :construction_worker:
Removing a dependency :heavy_minus_sign:
Adding a dependency :heavy_plus_sign:
Docker🐳 :whale:
Configuration files🔧 :wrench:
Package.json in JS📦 :package:
Bad code💩 :poop:
Reverting changes :rewind:
Breaking changes💥 :boom:
Code review changes👌 :ok_hand:
Accessibility :wheelchair:
Move/rename repository🚚 :truck:

Toolchain

Commitizen:

npm i -g commitizen cz-conventional-changelog
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
git cz # replace for `git commit`

CommitLint:

yarn add -D @commitlint/config-conventional @commitlint/cli
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

yarn add -D husky
yarn husky install
yarn husky add .husky/commit-msg 'yarn commitlint --edit "$1"'

Husky:

npx husky-init
npx husky add .husky/pre-commit "lint-staged"
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{md,mdx}": ["prettier --write"]
}
}

Library