commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/commit

/commit

Analyze changes, tidy up, create semantic commits, push.
分析变更,整理工作区,创建语义化提交并推送。

Role

角色

Engineer maintaining a clean, readable git history.
维护清晰、可读Git历史的工程师。

Objective

目标

Transform working directory changes into well-organized, semantically meaningful commits. Push to remote.
将工作目录中的变更转换为组织有序、语义明确的提交,并推送到远程仓库。

Latitude

自由度

  • Delete cruft, add to
    .gitignore
    , consolidate files as needed
  • Confirm before non-obvious deletions
  • Split changes into logical commits (one change per commit)
  • Skip quality gates if
    --quick
    flag or no package.json
  • 删除冗余文件,将文件添加到
    .gitignore
    ,按需合并文件
  • 在进行非明显的删除操作前需确认
  • 将变更拆分为逻辑提交(每次提交对应一项变更)
  • 若使用
    --quick
    标志或无package.json文件,则跳过质量检查环节

Workflow

工作流

  1. Analyze
    git status --short && git diff --stat HEAD
  2. Tidy — Categorize files: commit, gitignore, delete, consolidate. Execute cleanup.
  3. Group — Split into logical commits by type:
    feat:
    ,
    fix:
    ,
    docs:
    ,
    refactor:
    ,
    perf:
    ,
    test:
    ,
    build:
    ,
    ci:
    ,
    chore:
  4. Commit — One commit per group. Subject: imperative, lowercase, no period, ~50 chars. Body: why not what.
  5. Quality — Run available gates (
    pnpm lint
    ,
    typecheck
    ,
    test
    ,
    build
    ) unless
    --quick
  6. Push
    git fetch origin && git push origin HEAD
    (rebase if behind)
  1. 分析
    git status --short && git diff --stat HEAD
  2. 整理 — 对文件进行分类:提交、加入.gitignore、删除、合并。执行清理操作。
  3. 分组 — 按类型将变更拆分为逻辑提交:
    feat:
    ,
    fix:
    ,
    docs:
    ,
    refactor:
    ,
    perf:
    ,
    test:
    ,
    build:
    ,
    ci:
    ,
    chore:
  4. 提交 — 每组对应一次提交。提交标题:祈使语气、小写、无句号、约50字符。提交正文:说明原因而非内容。
  5. 质量检查 — 运行可用的检查环节(
    pnpm lint
    ,
    typecheck
    ,
    test
    ,
    build
    ),除非使用
    --quick
    标志
  6. 推送
    git fetch origin && git push origin HEAD
    (若落后则变基)

Flags

标志

  • --no-push
    /
    dry
    — Commit but don't push
  • --quick
    /
    fast
    — Skip quality gates
  • --amend
    — Amend last commit (use carefully)
  • --no-push
    /
    dry
    — 仅提交,不推送
  • --quick
    /
    fast
    — 跳过质量检查环节
  • --amend
    — 修改最后一次提交(谨慎使用)

Safety

安全注意事项

Never force push. Never push to main without confirmation. Always fetch before push.
切勿强制推送。未经确认切勿推送到main分支。推送前务必先拉取远程最新代码。