Good Git Commit Message
why good commit#
git commit 是当次 committing 更改的简短描述。良好的 commit message 不仅仅有利于与和他人合作,而且能很方便的追踪工作记录。
how to write#
commit message 格式
format: [emoji] <type>(scope): <message>
- emoji:options
- type: require
- scope:require
- message(description): require
type#
- feat: a new feature
- fix: a bug fix
- improvement: an improvement to a current feature
- docs: documention only chnage
- style: everything related to styling
- refactor: a code change that not neither a bug nor add a feat
- test: everything related to testing
- chore: updating build task,package manager config,etc
scope#
当前 commit 影响范围
descript#
当前 commit 简短描述
emojis type#
one style#
when adding a file or implementing a feature
when fixing a bug or issue
when improving code or comments
when improving performance
when updating docs or readme
when dealing with security
when updating dependencies or data
when a new release was built
when refactoring or removing linter warnings
when removing code or files
another style#
[tada] initial commit
[Add] when implementing a new feature
[Fix] when fixing a bug or issue
[Refactor] when refactor/improving code
[WIP]
[Minor] Some small updates
gitHook#
package.json
"githook": {
"pre-commit": "lint-staged",
"commit-msg": "node scripts/verifyCommitMsg.js"
}
scripts/verifyCommitMsg.js
const chalk = require("chalk");
// const msgPath = process.env.HUSKY_GIT_PARAMS;
const msgPath = process.env.GIT_PARAMS;
const msg = require("fs").readFileSync(msgPath, "utf-8").trim();
const commitRE =
/^(v\d+\.\d+\.\d+(-(alpha|beta|rc.\d+))?)|((revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types)(\(.+\))?!?: .{1,50})/;
if (!commitRE.test(msg)) {
console.error(
` ${chalk.bgRed.white(" ERROR ")} ${chalk.red(
`invalid commit message format.`
)}\n\n` +
chalk.red(
` Proper commit message format is required for automated changelog generation. Examples:\n\n`
) +
` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` +
` ${chalk.green(`fix(menu): handle events on blur (close #28)`)}\n\n` +
chalk.red(` See .gitlab/commit-convention.md for more details.\n`)
);
process.exit(1);
}
tools#
commitizen
gitmoji-cli
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix