Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>GitLab Commit GuardNew to Visual Studio Code? Get it now.
GitLab Commit Guard

GitLab Commit Guard

jasmine tang

| (0) | Free
Generate and validate GitLab-style commit messages inside VS Code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

gitlab-commit-guard

一个用于规范 GitLab commit 输入的轻量级工具,同时提供 VS Code 扩展命令。

它提供两类能力:

  • commit-msg hook 校验提交信息是否符合团队规范
  • prompt 交互式生成 commit message,减少手输出错
  • VS Code 命令面板里生成和校验 commit message

默认规范

默认采用以下格式:

<type>(<scope>): <subject>

Refs: [#123](https://github.com/your-account/gitlab-commit-guard/issues/123)

示例:

feat(user): add login audit log

Refs: [#128](https://github.com/your-account/gitlab-commit-guard/issues/128)

或:

fix: resolve null pointer on profile query

Closes: [group/project#245](https://github.com/group/project/issues/245)

VS Code 用法

安装扩展后,在命令面板中运行:

  • GitLab Commit Guard: Generate Commit Message
  • GitLab Commit Guard: Validate Commit Message

生成命令会:

  • 引导你依次输入 type、scope、subject、issue
  • 自动生成 commit message
  • 自动复制到剪贴板
  • 在新的编辑器标签页中打开结果

校验命令会:

  • 校验当前编辑器全文
  • 如果有选中文本,则只校验选中内容

可用命令

安装 hook:

node ./bin/gitlab-commit-guard.js install

校验单条提交信息:

node ./bin/gitlab-commit-guard.js validate --message "feat(api): add order query"

交互式生成提交信息:

node ./bin/gitlab-commit-guard.js prompt

直接发起 git commit:

node ./bin/gitlab-commit-guard.js prompt --commit

配置

在仓库根目录放置 .gitlab-commit-guard.json:

{
  "requireScope": false,
  "requireIssue": true,
  "issuePrefixes": ["Refs", "Closes"]
}

推荐接入方式

  1. 把这个项目发布为内部 npm 包,供团队统一安装。
  2. 在业务仓库执行 gitlab-commit-guard install 安装 commit-msg hook。
  3. 在团队规范中统一要求使用 prompt 或遵循同一 commit 格式。

发布到 VS Code Marketplace 前需要修改

发布前请先修改 package.json 中这两个字段:

  • publisher
  • repository.url
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft