commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Commit Command
Git Commit 命令
Create atomic git commits following Conventional Commits.
遵循Conventional Commits规范创建原子化的Git提交。
Flow
流程
-
Check state:
git status --porcelain- Empty → STOP, report "No changes to commit"
- Merge conflict markers → STOP, report conflict
-
Verify .gitignore excludes: secrets/, build artifacts, OS files (
.env), IDE configs.DS_Store -
Stage:(or specific files for atomic commits)
git add -A -
Analyze:and
git diff --cached --statgit diff --cached- If unrelated changes exist, split into separate commits via
git reset HEAD <file>
- If unrelated changes exist, split into separate commits via
-
Commit: Use Conventional Commits format
<type>(<scope>): <summary>
[body: what/why, wrap 72 chars]
[footer: BREAKING CHANGE: or Fixes #123]Types: | | | | | | | | |
featfixdocsstylerefactorperftestbuildcichoreSummary rules: imperative mood (e.g., "add", "fix", "refactor"), lowercase, no period, max 72 chars
- Confirm: → report hash and summary
git log -1 --oneline
-
检查状态:
git status --porcelain- 无内容 → 终止,提示“没有可提交的变更”
- 存在合并冲突标记 → 终止,报告冲突情况
-
验证.gitignore文件,确认已排除:机密文件/、构建产物、系统文件(
.env)、IDE配置文件.DS_Store -
暂存变更:(或针对原子提交暂存特定文件)
git add -A -
分析变更:和
git diff --cached --statgit diff --cached- 若存在无关变更,通过拆分到单独提交中
git reset HEAD <file>
- 若存在无关变更,通过
-
提交:使用Conventional Commits格式
<type>(<scope>): <summary>
[正文:说明变更内容/原因,每行不超过72字符]
[页脚:BREAKING CHANGE: 或 Fixes #123]类型可选值: | | | | | | | | |
featfixdocsstylerefactorperftestbuildcichore摘要规则:使用祈使语气(例如:"add"、"fix"、"refactor")、小写开头、无句点、最长72字符
- 确认提交:→ 报告提交哈希值和摘要信息
git log -1 --oneline
Output
输出结果
Success:
Failure: explain why and required action
Committed: <hash> <type>(<scope>): <summary>成功:
失败:说明失败原因及所需执行的操作
已提交: <hash> <type>(<scope>): <summary>