ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

一个Git Commit Message模板

2021-11-09 23:03:06  阅读:179  来源: 互联网

标签:Git Changes code build commit Commit Message 模板 change


一个统一的commit消息模板可以约束团队成员使用一致的方式提交变更信息,这样也方便集成工具进行合规检查。
通常来讲,commit信息应该包含如下内容:

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

type表示commit类型,可选值如下:
1.feat: A new feature
2.fix: A bug fix
3.docs: Documentation only changes
4.style: Changes that do not affect the meaning of the code (white-space, formatting, etc)
5.refactor: A code change that neither fixes a bug nor adds a feature
6.perf: A code change that improves performance
7.test: Adding missing tests or correcting existing tests
8.build: Changes that affect the build system or external dependencies (e.g: gulp, npm)
9.ci:Changes to our CI configuration files and scripts (e.g: Travis, Circle, BrowserStack)
10.chore: Other changes that don’t modify src or test files
11.revert: Reverts a previous commit

scope表示影响范围,如:route, component, utils, build等
subject表示commit概述,建议符合50/72 formatting
body表示具体修改的内容,可以分为多行,每一行建议符合50/72 formatting
footer是一些备注信息, 通常是BREAKING CHANGE或修复的BUG链接,如:issue #123

变更消息模板可以通过文件的方式固话下来,这样在每次提交变更的时候参照模板填写对应的信息。
一个完整的模板内容如下:


# head: <type>(<scope>): <subject>
# - type: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
# - scope: can be empty (eg. if the change is a global or difficult to assign to a single component), e.g: route, component, utils, build...
# - subject: start with verb (such as 'change'), 50-character line
#
# body: 72-character wrapped. Multiple lines separated by “-”, This should answer:
# * Why was this change necessary?
# * How does it address the problem?
# * Are there any side effects?
#
# footer: 
# - Include a link to the ticket, if any.
# - BREAKING CHANGE
#
# e.g:
# <type>(<scope>): <subject>
# <BLANK LINE>
# <body>
# <BLANK LINE>
# <footer>
# 
# types:
#
# feat:     A new feature 
# fix:      A bug fix 
# docs:     Documentation only changes 
# style:    Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) 
# refactor: A code change that neither fixes a bug nor adds a feature 
# perf:     A code change that improves performance 
# test:     Adding missing tests or correcting existing tests
# build:    Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) 
# ci:       Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) 
# chore:    Other changes that don't modify src or test files 
# revert:   Reverts a previous commit

可以将上述模板信息保存在文件"~/.gitmessage "中并添加为git的commit模板:
修改 ~/.gitconfig,添加:

[commit]
template = ~/.gitmessage

标签:Git,Changes,code,build,commit,Commit,Message,模板,change
来源: https://www.cnblogs.com/nuccch/p/15531386.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有