preface
When you use Git to manage a project, the project manager defines a specification for the code to commit when you set up the project. If you don’t follow the specification, you can’t commit the code, but it’s too much trouble to manually write the format every time you commit, hence commitizen.
This article explains how to use commitizen to quickly submit code to your team’s specifications. Interested developers are welcome to read this article.
Plug-in installation
- Install the CommITizen plug-in globally
yarn global add commitizen
Copy the code
The plug-in USES
- perform
git cz
Command to select the corresponding submission information
# Command parsing
What is the type of modification you want to make this time? Use arrow keys to select
Select the type of change that youResearch: (Use arrow keys) ❯ feat: A new feature # fix: A bug fix # Bug fix docs: Documentation only changes # md Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) A code change that neither fixes A bug nor adds A feature A code Change that Improves Performance Adding missing tests or correcting existing tests Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, NPM) 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 # does not modify SRC or test file changes
revert: Reverts a previous commit # Restore the last commit
## Scope of changes to commit this time
What is the scope of this change (e.g. component or file name): (press enter to skip) Enter the changed content and press Enter. Here is my content: design drawing
## Brief summary of the revised content of this submission, no more than 89 words
Write a short, imperative tense description of the change (max 89 chars):
(0) Enter the content of this change and press Enter. Here my content is: Design module add design drawing
## for the detailed description of the submitted modifications, use 1,2,3.. In numbers, each point is separated by a space
Provide a longer description of the change: (press enter to skip) 1. Add feedback design 2. Add file list design 3. Add account information design drawing
## Is there any significant change
Are there any breaking changes? (y/N) # Here I typed N
Whether this change will affect unresolved issues
Does this change affect any open issues? (y/N) # Here I typed N
Copy the code
- Finally, use VScode push
- Go to Github to see the effect, according to the pre-defined format successfully submitted
Write in the last
Webstorm, which I use all the time, has a plugin called Git-commit-Template that guides you through submitting code to the specification. However, some of my team members used VSCode as a development tool. I found no similar tools in the plug-in market, so I had to use Commitizen to submit on the command line.
-
Feel free to correct any mistakes in the comments section, and if this post helped you, feel free to like and follow 😊
-
This article was originally published in Nuggets and cannot be reproduced without permission at 💌