git-branch-format

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Branch Format Skill

Git分支命名格式技能

Generates a branch name from a description of changes.

根据变更描述生成分支名称

Convention

命名规范

With ticket number

带工单编号的情况

{type}/{TICKET_NUMBER}_{short_description}
  • TICKET_NUMBER
    is uppercase as provided by the user (e.g.
    PROJ-548
    )
  • short_description
    is
    snake_case
    , max 3 words — prefer 1–2
  • Example:
    feat/TICKET-548_flutter_upgrade
{type}/{TICKET_NUMBER}_{short_description}
  • TICKET_NUMBER
    采用用户提供的大写格式(例如
    PROJ-548
  • short_description
    使用
    snake_case
    命名法,最多3个单词——优先使用1-2个
  • 示例:
    feat/TICKET-548_flutter_upgrade

Without ticket number

不带工单编号的情况

{type}/{short_description}
  • short_description
    is
    snake_case
    , max 3 words — prefer 1–2
  • Example:
    feat/flutter_upgrade
Never use placeholders like
NO-TICKET
. If there's no ticket, just omit that part entirely.

{type}/{short_description}
  • short_description
    使用
    snake_case
    命名法,最多3个单词——优先使用1-2个
  • 示例:
    feat/flutter_upgrade
切勿使用
NO-TICKET
这类占位符。如果没有工单编号,直接省略该部分即可。

Type Selection Guide

类型选择指南

TypeWhen to use
feat
New functionality
fix
Bug fix
refactor
Code change with no behavior change
chore
Config, deps, tooling, maintenance
test
Adding or updating tests
docs
Documentation only
style
Formatting, whitespace
perf
Performance improvement
ci
CI/CD changes
build
Build system changes
revert
Reverting a previous commit

类型使用场景
feat
新增功能
fix
修复Bug
refactor
不改变功能的代码变更
chore
配置、依赖、工具、维护类工作
test
添加或更新测试
docs
仅修改文档
style
格式调整、空白字符修改
perf
性能优化
ci
CI/CD相关变更
build
构建系统变更
revert
回滚之前的提交

Workflow

工作流程

  1. Read the user's description of changes.
  2. Ask: "Do you have a ticket number for this?" — if the user doesn't provide one, proceed without it.
  3. Infer the correct
    type
    from the nature of the changes.
  4. Generate the branch name following the convention above.

  1. 读取用户的变更描述。
  2. 询问:“您有对应的工单编号吗?”——如果用户未提供,则直接跳过该部分。
  3. 根据变更的性质推断正确的
    type
  4. 按照上述规范生成分支名称。

Examples

示例

User: "I'm adding dark mode support" — Ticket: PROJ-312
feat/PROJ-312_dark_mode_support

User: "fixing a crash on the payment screen" — No ticket
fix/payment_screen_crash

User: "upgrading Flutter and fixing deprecated APIs" — Ticket: PROJ-548
feat/PROJ-548_flutter_upgrade
用户:“我要添加深色模式支持”——工单编号:PROJ-312
feat/PROJ-312_dark_mode_support

用户:“修复支付页面的崩溃问题”——无工单编号
fix/payment_screen_crash

用户:“升级Flutter并修复已废弃的API”——工单编号:PROJ-548
feat/PROJ-548_flutter_upgrade