Git Commit submission specification and the use of IDEA plug-in Git Commit Template

Git is the most powerful open source distributed version control system. It is commonly used in daily development to manage code submission, recovery, and tracking. It is the most commonly used code management tool for team development.

Before we modify the code and submit it, we often use git commit -m 'change'commands to describe the content of our code changes, but many of them are not standardized and can be seen everywhere git commit -m 'update', so that we can’t clearly know the changes of each submitted code, so we need a specification to Manage the content of code submissions.

1. Git Commit message specification

The commonly used Git Commit message specification uses the Angular specification .

This article refers to the introduction of Teacher Ruan's article:

http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html.

The format defined in the Angular specification has three contents:

  • Header
  • Body
  • Footer
<type>(<scope>): <subject>
// 空一行
<body>
// 空一行
<footer>

1、 Header

The header part has 3 fields: type (required), scope (optional), subject (required)

type (required): Type of change: Commit category;

scope (optional): Scope of this change: the influence module of this commit;

subject (required): Short description: a short description of the main content of this code change

(1)type

Type is used to describe the category of commit, and the commonly used identifiers are as follows:

  • feat: new features (feature)
  • fix: fix bug
  • docs: documentation
  • style: format (does not affect changes in code operation, spaces, formatting, etc.)
  • refactor: Refactoring (that is, it is not a new feature, nor is it a code change to modify a bug
  • perf: performance (changes to improve code performance)
  • test: add test or modify test
  • build: Changes that affect the build system or external dependencies (maven, gradle, npm, etc.)
  • ci: changes to CI configuration files and scripts
  • chore: Modifications to non-src and test directories
  • revert: Revert a commit

The two most commonly used types are feat and fix;

(2)scope

scopeUsed to describe the scope of the commit's influence, such as the data layer, control layer, view layer, etc., depending on the project.

(3)subject

subjectIt is a brief description of the purpose of commit, no more than 50 characters, and mainly introduces the main content of this code change.

For example:
eg: feat (order module): add the order number field to the order details interface

Among them, the feat corresponds to the type field; the order module corresponds to the scope (if the scope has content, the brackets exist); the "Order details interface adds the order number field" corresponds to the subject, which briefly explains the main content of the code change.

2、Body

The body part is a detailed description of this commit, which can be divided into multiple lines.

Such as:

(1) Increase the order number field;

(2) Added order refund interface;

In daily project development, if the subject in the Header has clearly described the content of the code change, the Body part can be empty.

3、Footer

(1) Incompatible changes

(2) Close Issue

Footer is not commonly used for development in daily projects and can be empty.

4、Revert

If you need to revoke the last commit, the header part is: revert: 上一次commit的header内容

The body part is: This reverts commit xxxxxx is the SHA identifier corresponding to the last commit.

2. Use of IDEA plug-in Git Commit Template

To submit code using the command line in iTerm, we can use Commitizen to write a qualified Commit message. For details, see: http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html.

This article mainly introduces how to use the plugin Git Commit Template in IDEA to write Commit message.

First install and download the plugin Git Commit Template: download address

Restart IDEA after installation, change the code, and click the VCS version control button in IDEA:

[External link image transfer failed. The origin site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-7Q5HG53I-1575635173932)(/Users/wanggenshen/Library/Application%20Support/typora-user-images/image- 20191206201909452.png)]

Click the Commit button:

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-9OaRl5Ol-1575635173933)(/Users/wanggenshen/Library/Application%20Support/typora-user-images/image- 20191206201954088.png)]

Select Type, fill in the corresponding content, and finally click Submit:

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-lQ6IVwbM-1575635173934)(/Users/wanggenshen/Library/Application%20Support/typora-user-images/image- 20191206202411883.png)]


Reference content

http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html

Guess you like

Origin blog.csdn.net/noaman_wgs/article/details/103429171