commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Command

Git Commit 命令

Create atomic git commits following Conventional Commits.
遵循Conventional Commits规范创建原子化的Git提交。

Flow

流程

  1. Check state:
    git status --porcelain
    • Empty → STOP, report "No changes to commit"
    • Merge conflict markers → STOP, report conflict
  2. Verify .gitignore excludes: secrets/
    .env
    , build artifacts, OS files (
    .DS_Store
    ), IDE configs
  3. Stage:
    git add -A
    (or specific files for atomic commits)
  4. Analyze:
    git diff --cached --stat
    and
    git diff --cached
    • If unrelated changes exist, split into separate commits via
      git reset HEAD <file>
  5. Commit: Use Conventional Commits format
<type>(<scope>): <summary>

[body: what/why, wrap 72 chars]

[footer: BREAKING CHANGE: or Fixes #123]
Types:
feat
|
fix
|
docs
|
style
|
refactor
|
perf
|
test
|
build
|
ci
|
chore
Summary rules: imperative mood (e.g., "add", "fix", "refactor"), lowercase, no period, max 72 chars
  1. Confirm:
    git log -1 --oneline
    → report hash and summary
  1. 检查状态
    git status --porcelain
    • 无内容 → 终止,提示“没有可提交的变更”
    • 存在合并冲突标记 → 终止,报告冲突情况
  2. 验证.gitignore文件,确认已排除:机密文件/
    .env
    、构建产物、系统文件(
    .DS_Store
    )、IDE配置文件
  3. 暂存变更
    git add -A
    (或针对原子提交暂存特定文件)
  4. 分析变更
    git diff --cached --stat
    git diff --cached
    • 若存在无关变更,通过
      git reset HEAD <file>
      拆分到单独提交中
  5. 提交:使用Conventional Commits格式
<type>(<scope>): <summary>

[正文:说明变更内容/原因,每行不超过72字符]

[页脚:BREAKING CHANGE: 或 Fixes #123]
类型可选值
feat
|
fix
|
docs
|
style
|
refactor
|
perf
|
test
|
build
|
ci
|
chore
摘要规则:使用祈使语气(例如:"add"、"fix"、"refactor")、小写开头、无句点、最长72字符
  1. 确认提交
    git log -1 --oneline
    → 报告提交哈希值和摘要信息

Output

输出结果

Success:
Committed: <hash> <type>(<scope>): <summary>
Failure: explain why and required action
成功:
已提交: <hash> <type>(<scope>): <summary>
失败:说明失败原因及所需执行的操作