Git 提交模板,git-commit-plugin使用与配置

1,676 阅读1分钟

每次大家看到很优雅的提交 message 的时候 有没有想过,它是怎么出来的 手动敲的? 今天跟大家分享一下 git-commit-plugin 的使用与配置

下载

直接在 VSCode 插件市场搜索 git-commit-plugin 进行安装

screenshot-20231227-172552.png

基本使用

安装完插件之后,会在这里出现一个图标

screenshot-20231227-172939.png 在我们 git add . 之后,会出现提交模板,根据自己的改动,选择一个提交模板

screenshot-20231227-173044.png 选择后会出现信息提交选择框,这里可以只选择 Subject 概述(即你的改动信息),然后点击 Complete 完成提交信息

screenshot-20231227-173216.png 完成后,即展示完成提交 message,点击提交即可

screenshot-20231227-173647.png

高级配置

可以自定义模板&提交类型

screenshot-20231227-173919.png

    "GitCommitPlugin.CustomCommitType": [
      {
        "key": "fix", 
        "label": "fix",
        "detail": "fix",
        "icon":"🐛"
       }
    ],
    "GitCommitPlugin.Templates": [
        {
            "templateName": "git-cz",
            "templateContent": "<type>(<scope>):<space><icon><space><subject><enter><body><enter><footer>",
             // Set as default commit template
            "default":true
        }
    ],

可以根据以上模板进行提交模板修改