Java开发-实际工作经验和技巧-0003-容易被忽视的Git提交代码规范

Java开发-实际工作经验和技巧-0003-容易被忽视的Git提交代码规范

更多内容欢迎关注我(持续更新中,欢迎Star✨)

Github:CodeZeng1998/Java-Developer-Work-Note

技术公众号:CodeZeng1998(纯纯技术文)

生活公众号:好锅(Life is more than code)

CSDN: CodeZeng1998

其他平台:CodeZeng1998好锅


本文分享一个容易被大家忽视的 Git 里面的规范相关的内容,那就是提交信息的编写规范

好的 Git 的提交信息,要满足几个条件:

  • 简单易懂
  • 容易区分
  • 一次提交尽可能只跟一个功能相关

下面介绍详细的内容,大家可以按照这个规范来进行 Git 提交信息的编写(推荐),或者按照公司自定义规范进行相应的提交信息的编写。


提交信息的格式如下:

<type>(<scope>): <subject>

<body>

BREAKING CHANGE: <changes>

Closes <closes>

<skipCi>
  • type :提交类型
  • scope:范围
  • subject:简短描述
  • body:详细描述

In file templates, you can use text, code, comments, and predefined variables. The following provides a list of predefined variables.

Predefined variables take the following values:

标识含义
${type}Corresponds to the submission menu ‘Type of change’
${scope}Corresponds to the submission menu ‘Scope of this change’
${subject}Corresponds to the submission menu ‘Short description’
${body}Corresponds to the submission menu ‘Long description’
${changes}Corresponds to the submission menu ‘Breaking changes’
${closes}Corresponds to the submission menu ‘Closed issues’
${skipCi}Corresponds to the submission menu ‘Skip CI’
${newLine}’ ', indicating whether to wrap the line

最常用的其实是如下模板:即 类型(范围): 简短信息

<type>(<scope>): <subject>

下面介绍一下 type 的详细使用:

类型种类含义
featA new feature
fixA bug fix
docsDocumentation only changes
styleChanges that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactorA code change that neither fixes a bug nor adds a feature
perfA code change that improves performance
testAdding missing tests or correcting existing tests
buildChanges that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ciChanges to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
choreOther changes that don’t modify src or test files
revertReverts a previous commit

常用的 type 主要有以下几个:

  • type:新的特性,新的功能点
  • fix: 修复一个 bug
  • docs:只有文档相关内容变更
  • style:代码风格变更(代码格式、空格、空行等)
  • perf :性能优化
  • test:测试相关内容

如果使用的开发工具是 IDEA,推荐使用插件 Git Commit Message Helper,习惯之后就可以自己按照上述格式进行 Git 提交信息的编写即可。

下面给出几个符合上述规范的 Git 提交信息的例子:

  • feat(用户模块): 新增用户列表查询功能;
  • fix(用户模块): 修改用户列表查询分页错误bug;
  • docs(用户模块): 增加对应的用户角色文档说明;
  • style(用户模块): 更改代码风格;
  • perf(用户模块): 引入Reids缓存对用户列表查询功能进行优化;
  • test用户模块): 增加用户列表查询功能的单元测试;

建议:

  • Git 的提交信息按照上述规范进行编写
  • 一次性提交的内容尽可能的少,并且不相关的内容分开进行提交

在这里插入图片描述

上图由 Pic 生成

关键词:A bustling market street in an ancient city


更多内容欢迎关注我(持续更新中,欢迎Star✨)

Github:CodeZeng1998/Java-Developer-Work-Note

技术公众号:CodeZeng1998(纯纯技术文)

生活公众号:好锅(Life is more than code)

CSDN: CodeZeng1998

其他平台:CodeZeng1998好锅

  • 29
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值