Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Commit Template HelperNew to Visual Studio Code? Get it now.
Git Commit Template Helper

Git Commit Template Helper

zhubin

|
216 installs
| (0) | Free
一个帮助在Git提交时使用标准化提交信息模板的VSCode扩展
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Commit Template Helper

一个用于「在 Git 提交信息前快速追加结构化前缀 / 标签」的 VSCode 扩展。

适用场景:

  • 希望统一 commit 前缀(如 ✨feat: / 🐛fix: / 📚docs:),避免每次手敲;
  • 希望在提交前面加上类似 [all]、[only_current]、[pending] 这类 范围 / 意图标签,方便后续回溯、筛选和 cherry-pick;并且适用于单仓库、多主分支、多客户订制化场景;
  • 不想改 Git 行为,只想改「提交信息怎么写」。

注意:本扩展只会修改提交信息文本,不会自动执行合并、cherry-pick,也不会触发任何 CI/CD 行为。

功能特点

  • 在源代码管理视图中添加一个 提交模板按钮,点击后显示提交模板列表(例如 feat: / fix: / docs: 或自定义的 [all] 等)
  • 新增一个 额外标签按钮,用于在当前提交信息末尾快速追加结构化标签(如 [all]、[only_current]、[pending]、[risk_low])
  • 支持自定义提交模板和额外标签,包括 emoji 和自定义前缀
  • 选择模板后自动填充到提交信息输入框中
  • 可选:选择模板后自动弹出额外标签下拉,提高一次性选择效率
  • 默认提供一组通用提交类型模板,开箱即可使用

安装

  1. 打开 VSCode
  2. 按下Ctrl+Shift+X(Windows/Linux)或Cmd+Shift+X(macOS)打开扩展视图
  3. 搜索"Git Commit Template Helper"
  4. 点击"安装"按钮

使用方法

  1. 在 VSCode 中打开一个 Git 仓库
  2. 进行代码修改后,切换到源代码管理视图(Git 图标)
  3. 在源代码管理视图标题栏右侧,可以看到两个图标:
    • 提交模板按钮(type 图标):用于选择提交前缀模板
    • 额外标签按钮(tag 图标):用于追加额外标签
  4. 点击提交模板按钮,从弹出的列表中选择一个提交模板
  5. 选择后,模板会自动填充到提交信息输入框中
  6. 如需追加范围/线路等标签,点击额外标签按钮,从下拉中选择一个标签,插件会将其追加到当前提交信息末尾
  7. 补充具体的提交信息,然后提交

配置选项

方式一:通过 VSCode 设置界面

  1. 打开 VSCode 设置(文件 > 首选项 > 设置)
  2. 搜索"git-commit-template-helper"
  3. 编辑"Git 提交模板助手: Commit Templates"设置

方式二:直接编辑 settings.json

  1. 打开 VSCode 设置(文件 > 首选项 > 设置)
  2. 点击右上角的"打开设置(json)"图标
  3. 添加或修改以下配置:
{
  "git-commit-template-helper.commitTemplates": [
    {
      "label": "feat: 新增功能",
      "value": "✨feat: "
    },
    {
      "label": "fix: 修复Bug",
      "value": "🐛fix: "
    }
    // 添加更多自定义模板...
  ]
}

配置项说明

当前扩展提供三个主要配置项:

  • git-commit-template-helper.commitTemplates

    • 类型:数组
    • 作用:控制「提交模板按钮」下拉列表的内容。
    • 每个提交模板包含两个属性:
      • label: 显示在选择列表中的文本(不包含 emoji)
      • value: 选择后填充到提交信息输入框中的文本(包含 emoji)
  • git-commit-template-helper.extraTags

    • 类型:数组
    • 作用:控制「额外标签按钮」下拉列表的内容。
    • 每个额外标签包含以下属性:
      • label: 显示在额外标签下拉列表中的文本(通常包含 emoji 和标签名)
      • value: 实际追加到提交信息中的文本(推荐使用 [xxx] 形式)
      • description(可选):在下拉列表中展示的说明文字
  • git-commit-template-helper.autoShowExtraTagAfterTemplate

    • 类型:布尔值(boolean)
    • 默认值:false
    • 作用:控制是否在选择提交模板后,自动弹出额外标签下拉(相当于自动执行一次 appendExtraTag 命令)。

默认提交类型

如果您没有自定义配置,插件将使用以下默认模板:

显示文本 实际提交格式 说明
feat: 新增功能 ✨feat: 新功能开发
fix: 修复 Bug 🐛fix: Bug 修复
chore: 非功能性更改 🚀chore: 非功能性更改
docs: 文档更新 📚docs: 文档更新
style: 样式修改 💄style: 代码格式调整
refactor: 代码重构 ♻️refactor: 代码重构
test: 添加测试 ✅test: 测试用例
ui: 界面样式调整 🎨ui: UI 相关更改
build: 构建相关 🔧build: 构建系统或外部依赖更改
ci: CI 配置更改 🔨ci: CI 配置更改
perf: 性能优化 ⚡️perf: 性能优化
revert: 回退更改 ⏪️revert: 回退之前的提交

自定义配置示例

以下是一个自定义配置的完整示例:

{
  "git-commit-template-helper.commitTemplates": [
    {
      "label": "feat: 新增功能",
      "value": "✨feat: "
    },
    {
      "label": "fix: 修复Bug",
      "value": "🐛fix: "
    },
    {
      "label": "docs: 文档更新",
      "value": "📚docs: "
    },
    {
      "label": "style: 样式修改",
      "value": "💄style: "
    },
    {
      "label": "refactor: 代码重构",
      "value": "♻️refactor: "
    },
    {
      "label": "test: 添加测试",
      "value": "✅test: "
    },
    {
      "label": "chore: 其他更改",
      "value": "🚀chore: "
    }
  ],
  "git-commit-template-helper.extraTags": [
    {
      "label": "� all",
      "value": "[all]",
      "description": "Change is intended to be synced to all main branches/environments"
    },
    {
      "label": "� fix_all",
      "value": "[fix_all]",
      "description": "Bug fix that should be applied wherever the affected code exists"
    },
    {
      "label": "🔒 only_current",
      "value": "[only_current]",
      "description": "Change is only for the current branch or scenario"
    },
    {
      "label": "🚑 hotfix",
      "value": "[hotfix]",
      "description": "Urgent fix, sync scope should be decided explicitly"
    },
    {
      "label": "⏸ pending",
      "value": "[pending]",
      "description": "Sync scope not decided yet"
    },
    {
      "label": "✅ risk_low",
      "value": "[risk_low]",
      "description": "Low risk change; generally safe to roll out"
    },
    {
      "label": "⚠️ risk_high",
      "value": "[risk_high]",
      "description": "High risk change; review carefully before syncing"
    }
  ],
  "git-commit-template-helper.autoShowExtraTagAfterTemplate": true
}

提示:autoShowExtraTagAfterTemplate 为可选配置,默认不自动弹出额外标签下拉; 如需在选择提交模板后立刻弹出额外标签选择,可以手动将其设置为 true。

开发指南

如果您想要修改或扩展此插件,可以按照以下步骤进行:

  1. 克隆仓库

    git clone https://github.com/yourusername/git-commit-template-helper.git
    cd git-commit-template-helper
    
  2. 安装依赖

    npm install
    
  3. 打开 VSCode

    code .
    
  4. 按 F5 启动调试

  5. 在新打开的 VSCode 窗口中测试插件

贡献

欢迎提交问题和功能请求!如果您想贡献代码,请随时提交 Pull Request。

许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft