Code Monkey home page Code Monkey logo

lindage1994.github.io's People

Contributors

lianlianer2020 avatar lindage1994 avatar

Watchers

 avatar  avatar

lindage1994.github.io's Issues

Git Commit message 规范

Git Commit message 规范

介绍

在 Git 中,每次提交代码,都要写 Commit message(提交说明),否则就不允许提交。这个操作将通过 git commit 完成。

git commit -m "hello world"

上面代码的-m参数,就是用来指定 commit message 的。

如果一行不够,可以只执行git commit,就会跳出文本编译器,让你写多行。

git commit

格式

Commit message 包括三个部分:Header,Body 和 Footer。可以用下方的格式表示它的结构。

<type>(<scope>): <subject>
// 空一行
<body>
// 空一行
<footer>

其中,Header 是必需的,Body 和 Footer 可以省略(默认忽略),一般我们在 git commit 提交时指定的 -m 参数,就相当于默认指定 Header。

不管是哪一个部分,任何一行都不得超过72个字符(或100个字符)。这是为了避免自动换行影响美观。

Header

Header部分只有一行,包括三个字段:type(必需)、scope(可选)和subject(必需)。

type
  • feat:新功能(feature)
  • fix:修补bug
  • docs:文档(documentation)
  • style: 格式(不影响代码运行的变动)
  • refactor:重构(即不是新增功能,也不是修改bug的代码变动)
  • test:增加测试
  • chore:构建过程或辅助工具的变动
    如果 type 为 feat 和 fix ,则该 commit 将肯定出现在 Change log 之中。其他情况(docs、chore、style、refactor、test)由你决定,要不要放入 Change log,建议是不要。
scope

scope用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视仓库不同而不同。

subject

subject是 commit 目的的简短描述,不超过50个字符。

以动词开头,使用第一人称现在时,比如change,而不是changed或changes
第一个字母小写
结尾不加句号(.)

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

有两个注意点。

使用第一人称现在时,比如使用change而不是changed或changes。
应该说明代码变动的动机,以及与以前行为的对比。

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` wasn't generaly useful for directives so there should be no code using it.

2、关闭 Issue
如果当前 commit 针对某个issue,那么可以在 Footer 部分关闭这个 issue 。

Closes #234

也可以一次关闭多个 issue 。

Closes #123, #245, #992

Revert

还有一种特殊情况,如果当前 commit 用于撤销以前的 commit,则必须以revert:开头,后面跟着被撤销 Commit 的 Header。

revert: feat(pencil): add 'graphiteWidth' option

This reverts commit 667ecc1654a317a13331b17617d973392f415f02.

Body部分的格式是固定的,必须写成This reverts commit .,其中的hash是被撤销 commit 的 SHA 标识符。

如果当前 commit 与被撤销的 commit,在同一个发布(release)里面,那么它们都不会出现在 Change log 里面。如果两者在不同的发布,那么当前 commit,会出现在 Change log 的Reverts小标题下面。

本文摘自 阮一峰 博客 《Git Commit message 编写指南》

苦昼短

飞光飞光,劝尔一杯酒。
吾不识青天高,黄地厚,
唯见月寒日暖,来煎人寿。
食熊则肥,食蛙则瘦。
神君何在,太一安有。
天东有若木,下置衔烛龙。
吾将斩龙足,嚼龙肉。
使之朝不得回,夜不得伏。
自然老者不死,少者不哭。
何为服黄金,吞白玉。
谁似任公子,云中骑碧驴。
刘彻茂陵多滞骨,嬴政梓棺费鲍鱼。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.