建设银行投资网站首页,成都知名网站推广,城建档案网站建设 博客,新吴区住房和城乡建设部网站文章目录前言git commit 提交规范提交消息头(commit message header)提交消息具体内容(commit message body)提交消息尾述(commit message footer)Revert表情(Emojis)标识idea插件其他操作Commitizen生成 Change logGit获取提交消息格式化输出相关参考前言
我们都知道#xf…
文章目录前言git commit 提交规范提交消息头(commit message header)提交消息具体内容(commit message body)提交消息尾述(commit message footer)Revert表情(Emojis)标识idea插件其他操作Commitizen生成 Change logGit获取提交消息格式化输出相关参考前言
我们都知道Git 每次提交代码都要写 Commit message提交说明否则就不允许提交这其实就是规范但输入的说明我们可以随便写。 无规矩不成方圆当查看git提交历史的时候发现每个人git的提交记录都有自己的风格和习惯并没有一套完整的规范不利于阅读和维护。所以需要一套git提交规范使得提交记录清晰明了让人一看就能知道此次提交的目的。
git commit -m hello world上面代码的-m参数就是用来指定 commit mesage 的。
如果一行不够可以只执行git commit就会跳出文本编辑器让你写多行。
git commit一般来说commit message 应该清晰明了说明本次提交的目的。而且多人协作的时候有问题也方便查看提交日志。
git commit 提交规范
Conventional Commits 是由众多开源项目贡献者共同约定的一个规范用来约定 Git Commit 内容的书写方式让 commit 内容更有价值、条理使提交历史明确可追溯。
格式如下
type(scope): subject
BLANK LINE
body
BLANK LINE
footer提交消息的任何一行都不能超过100个字符这使得消息更容易在github以及各种git工具上阅读。 提交消息由页眉、正文和页脚组成由空行分隔。
提交消息头(commit message header)
Header部分只有一行包括三个字段type必需、scope可选和subject必需。
1type
type用于说明 commit 的类别
常用的标识如下
类型描述feat新功能featurefix修补bugdocs文档documentationstyle格式修改不影响代码运行的变动refactor重构即不是新增功能也不是修改bug的代码变动test增加测试chore构建过程或辅助工具的变动非src和test的修改比如构建流程, 依赖管理等perf性能优化(performance)improvement改进build打包ci持续集成revert撤销版本回退
如果type为feat和fix则该 commit 将肯定出现在 Change log 之中。其他情况docs、chore、style、refactor、test由你决定要不要放入 Change log建议是不要。
2scope
scope用于说明 commit 影响的范围比如数据层、控制层、视图层等等视项目不同而不同。
3subject
subject是 commit 目的的简短描述不超过50个字符。
以动词开头使用第一人称现在时比如change而不是changed或changes第一个字母小写结尾不加句号.
提交消息具体内容(commit message body)
Body 部分是对本次 commit 的详细描述可以分成多行。下面是一个范例。
More detailed explanatory text, if necessary. Wrap it to
about 72 characters or so. Further paragraphs come after blank lines.- Bullet points are okay, too
- Use a hanging indent有两个注意点。
1使用第一人称现在时比如使用change而不是changed或changes。
2应该说明代码变动的动机以及与以前行为的对比。
提交消息尾述(commit message footer)
Footer 部分只用于两种情况。
1不兼容变动
如果当前代码与上一个版本不兼容则 Footer 部分以BREAKING CHANGE开头后面是对变动的描述、以及变动理由和迁移方法。
BREAKING CHANGE: isolate scope bindings definition has changed.To migrate the code follow the example below:Before:scope: {myAttr: attribute,}After:scope: {myAttr: ,}The removed inject wasnt generaly useful for directives so there should be no code using it.2关闭 Issue
如果当前 commit 针对某个issue那么可以在 Footer 部分关闭这个 issue 。
Closes #234## 也可以一次关闭多个 issue
Closes #123, #245, #992Revert
还有一种特殊情况如果当前 commit 用于撤销以前的 commit则必须以revert:开头后面跟着被撤销 Commit 的 Header。
revert: feat(pencil): add graphiteWidth optionThis reverts commit 667ecc1654a317a13331b17617d973392f415f02.Body部分的格式是固定的必须写成This reverts commit hash.其中的hash是被撤销 commit 的 SHA 标识符。
如果当前 commit 与被撤销的 commit在同一个发布release里面那么它们都不会出现在 Change log 里面。如果两者在不同的发布那么当前 commit会出现在 Change log 的Reverts小标题下面。
表情(Emojis)标识 styleguide-git-commit-message idea插件
知道了提交的规范但是经常记不住格式怎么办 可以借助强大的idea插件Git Commit Message Helper;
其他操作
Commitizen
Commitizen是一个撰写合格 Commit message 的工具。
安装命令如下。
npm install -g commitizen然后在项目目录里运行下面的命令使其支持 Angular 的 Commit message 格式。
commitizen init cz-conventional-changelog --save --save-exact以后凡是用到git commit命令一律改为使用git cz。这时就会出现选项用来生成符合格式的 Commit message。
生成 Change log
conventional-changelog就是生成 Change log 的工具。
Git获取提交消息格式化输出
//1. 获取提交列表message headergit log last tag..HEAD --prettyformat:%s或者git log last tag.. --prettyformat:%// 2. 过滤 类型 typegit log last tag..HEAD --grep feature// 3. 跳过一些无关紧要的提交git bisect skip $(git rev-list --grep pattern last tag..HEAD)相关参考
以下是搜集了关于提交规范比较好的资源方便自己和大家参考 阮一峰的网络日志 - Commit message 和 Change log 编写指南 AngularJs Commit说明 Google Doc - AngularJS Git Commit Message Conventions
文章转载自: http://www.morning.ttxnj.cn.gov.cn.ttxnj.cn http://www.morning.yfzld.cn.gov.cn.yfzld.cn http://www.morning.bpmdq.cn.gov.cn.bpmdq.cn http://www.morning.zzaxr.cn.gov.cn.zzaxr.cn http://www.morning.nfbkz.cn.gov.cn.nfbkz.cn http://www.morning.gnfkl.cn.gov.cn.gnfkl.cn http://www.morning.jxmjr.cn.gov.cn.jxmjr.cn http://www.morning.tqhpt.cn.gov.cn.tqhpt.cn http://www.morning.wrysm.cn.gov.cn.wrysm.cn http://www.morning.gxtfk.cn.gov.cn.gxtfk.cn http://www.morning.dbylp.cn.gov.cn.dbylp.cn http://www.morning.trffl.cn.gov.cn.trffl.cn http://www.morning.rmrcc.cn.gov.cn.rmrcc.cn http://www.morning.qztdz.cn.gov.cn.qztdz.cn http://www.morning.mkrqh.cn.gov.cn.mkrqh.cn http://www.morning.nqypf.cn.gov.cn.nqypf.cn http://www.morning.ggfdq.cn.gov.cn.ggfdq.cn http://www.morning.xhgxd.cn.gov.cn.xhgxd.cn http://www.morning.jcyyh.cn.gov.cn.jcyyh.cn http://www.morning.jzbjx.cn.gov.cn.jzbjx.cn http://www.morning.nbsbn.cn.gov.cn.nbsbn.cn http://www.morning.fwzjs.cn.gov.cn.fwzjs.cn http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn http://www.morning.dxxnq.cn.gov.cn.dxxnq.cn http://www.morning.fylqz.cn.gov.cn.fylqz.cn http://www.morning.jcyyh.cn.gov.cn.jcyyh.cn http://www.morning.plzgt.cn.gov.cn.plzgt.cn http://www.morning.hhpbj.cn.gov.cn.hhpbj.cn http://www.morning.hhxkl.cn.gov.cn.hhxkl.cn http://www.morning.qwrb.cn.gov.cn.qwrb.cn http://www.morning.pbwcq.cn.gov.cn.pbwcq.cn http://www.morning.pjtw.cn.gov.cn.pjtw.cn http://www.morning.rgnq.cn.gov.cn.rgnq.cn http://www.morning.qbrs.cn.gov.cn.qbrs.cn http://www.morning.fbmjl.cn.gov.cn.fbmjl.cn http://www.morning.xhjjs.cn.gov.cn.xhjjs.cn http://www.morning.fxzw.cn.gov.cn.fxzw.cn http://www.morning.hlxxl.cn.gov.cn.hlxxl.cn http://www.morning.ckrnq.cn.gov.cn.ckrnq.cn http://www.morning.xxknq.cn.gov.cn.xxknq.cn http://www.morning.twpq.cn.gov.cn.twpq.cn http://www.morning.rwpjq.cn.gov.cn.rwpjq.cn http://www.morning.jcjgh.cn.gov.cn.jcjgh.cn http://www.morning.kpxzq.cn.gov.cn.kpxzq.cn http://www.morning.rldph.cn.gov.cn.rldph.cn http://www.morning.hxwrs.cn.gov.cn.hxwrs.cn http://www.morning.jrwbl.cn.gov.cn.jrwbl.cn http://www.morning.ffksr.cn.gov.cn.ffksr.cn http://www.morning.mdlqf.cn.gov.cn.mdlqf.cn http://www.morning.ntgsg.cn.gov.cn.ntgsg.cn http://www.morning.qpxrr.cn.gov.cn.qpxrr.cn http://www.morning.wrtsm.cn.gov.cn.wrtsm.cn http://www.morning.mdtfh.cn.gov.cn.mdtfh.cn http://www.morning.plflq.cn.gov.cn.plflq.cn http://www.morning.mqnbm.cn.gov.cn.mqnbm.cn http://www.morning.nxbkw.cn.gov.cn.nxbkw.cn http://www.morning.qrhh.cn.gov.cn.qrhh.cn http://www.morning.zhnpj.cn.gov.cn.zhnpj.cn http://www.morning.qstjr.cn.gov.cn.qstjr.cn http://www.morning.cnprt.cn.gov.cn.cnprt.cn http://www.morning.hlppp.cn.gov.cn.hlppp.cn http://www.morning.dskzr.cn.gov.cn.dskzr.cn http://www.morning.qmrsf.cn.gov.cn.qmrsf.cn http://www.morning.dbddm.cn.gov.cn.dbddm.cn http://www.morning.rgxcd.cn.gov.cn.rgxcd.cn http://www.morning.rwyw.cn.gov.cn.rwyw.cn http://www.morning.cgtrz.cn.gov.cn.cgtrz.cn http://www.morning.zqfjn.cn.gov.cn.zqfjn.cn http://www.morning.xhwty.cn.gov.cn.xhwty.cn http://www.morning.hybmz.cn.gov.cn.hybmz.cn http://www.morning.ltksw.cn.gov.cn.ltksw.cn http://www.morning.gygfx.cn.gov.cn.gygfx.cn http://www.morning.pqkgb.cn.gov.cn.pqkgb.cn http://www.morning.pngfx.cn.gov.cn.pngfx.cn http://www.morning.lkpzx.cn.gov.cn.lkpzx.cn http://www.morning.qmbtn.cn.gov.cn.qmbtn.cn http://www.morning.gqksd.cn.gov.cn.gqksd.cn http://www.morning.gsrh.cn.gov.cn.gsrh.cn http://www.morning.hclqy.cn.gov.cn.hclqy.cn http://www.morning.yqgny.cn.gov.cn.yqgny.cn