The profile
Normative Git submission facilitates team collaboration, locating bugs, and finding functional code. In addition, normative Git submission can generate a Changelog.md file through the tool, making it easy for developers or users to track the development information and features of a project.
This paper is worth thinking about three aspects:
- How can git commit information be regulated, and by what specification?
- How to verify user submission information?
- How to generate
CHANGELOG.md
file
Standardize the practice steps for Git commits
Initialize the project and install dependencies
// Start with an empty Git project yarn init -y // Install commitizen sudo YARN Global add Commitizen // install @commitLint /cli yarn add @commitlint/cli -d // Install @commitlint/config-conventional YARN add @commitlint/config-conventional -d // Install Convention-changelog yarn add convention-changelog -d // Install convention-changelog -CLI yarn add Common-changelog - CLI -d // Install CZ-xcom - Changelog YARN add CZ-xcom - Changelog -d // Install Husky YARN Add [email protected] -d // Install rimraf yarn add rimraf -dCopy the code
2. Modify package.json
Modify package.json by adding the following code
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"}},"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}},"scripts": {
"log": "rimraf CHANGELOG.md && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
}
Copy the code
Add the configuration file, commitlint.config.js, in the root directory to specify the verification rules
module.exports = {
extends: ['@commitlint/config-conventional']}Copy the code
Note: Commitlint/config-Conventional is a validation rule that complies with the Angular specification
How to use
1. Direct submission:
Git commit -m "Chore: Commit Message" git commit -m "Chore: Commit Message"Copy the code
Use git cz instead of git commit
Git cz launches a tool to automatically generate git commit information
git cz
Copy the code
Conforming to the standard of the code
Type (required), scope (optional), and subject (required). <type>(<scope>): <subject>Copy the code
The value of type has the following types:
reference
This article is a summary of the Cz toolset usage introduction – Specification Git submission instructions. Thank you for sharing