天天看點

我是怎麼寫 Git Commit message 的?

目錄

  • 作用
  • 用的什麼規範?
    • type
    • scope
    • subject
    • body
    • footer
    • 參考文章
  • 用的什麼輔助工具?

編寫格式化的

commit message

能夠大大提高代碼的維護效率。

比如:

  • 可以提供更多的曆史資訊,友善快速浏覽;
  • 可以過濾某些

    commit

    (比如文檔改動),便于快速查找資訊;
  • 可以直接從

    commit

    生成

    Change log

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

其中,Header 是必需的,Body 和 Footer 可以省略。

type

用于說明 commit 的類别。

  • feature

    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

scope

用于說明 commit 影響的範圍,比如資料層、控制層、視圖層、具體子產品等等,視項目不同而不同。

subject

是 commit 目的的簡短描述,不超過50個字元。

Body

部分是對本次 commit 的較長的描述,可以分成多行。

BREAKING CHANGE

,用來描述目前 commit 與上一個版本不相容的地方。

Issue

,用來描述目前 commit 針對的某個issue。

Commit message 和 Change log 編寫指南

太教條了,太累... 給大家分享一個我使用的工具。

JetBrains IDE

插件,在

GoLand

PhpStorm

中 都可以在插件市場搜尋

Git Commit Message Helper

插件位址:Git Commit Message Helper

安裝後效果,在 git commit 時:

我是怎麼寫 Git Commit message 的?
我是怎麼寫 Git Commit message 的?

咱們看一下效果:

我是怎麼寫 Git Commit message 的?
我是怎麼寫 Git Commit message 的?

這時,點選 Commit 或 Commit and Push... 即可。

趕快去體驗吧,有問題歡迎來的星球交流讨論 https://t.zsxq.com/iIUVVnA

我是怎麼寫 Git Commit message 的?

作者:新亮筆記(關注公衆号,可申請添加微信好友)

出處:https://www.cnblogs.com/xinliangcoder

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接,否則保留追究法律責任的權利。