commit-push
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit and Push
提交与推送
Commit all local changes following Conventional Commits format and push to remote.
遵循Conventional Commits格式提交所有本地变更并推送至远程仓库。
Step 1: Gather Context
步骤1:收集上下文
Run these commands in parallel to understand the changes:
bash
undefined并行运行以下命令以了解变更情况:
bash
undefinedSee all untracked and modified files
查看所有未跟踪和已修改的文件
git status
git status
See staged and unstaged changes
查看暂存和未暂存的变更
git diff
git diff --cached
git diff
git diff --cached
See recent commit messages for style reference
查看最近的提交信息以参考格式
git log --oneline -10
undefinedgit log --oneline -10
undefinedStep 2: Analyze Changes
步骤2:分析变更
Review the changes and determine:
-
Type: What kind of change is this?
- - New feature or capability
feat - - Bug fix
fix - - Documentation only
docs - - Code restructure without behavior change
refactor - - Adding or updating tests
test - - Maintenance, dependency updates
chore - - Performance improvement
perf - - CI/CD changes
ci
-
Scope: Which component is affected?
- Examine the changed files and determine the appropriate scope
- Use consistent scope names within the project (check for patterns)
git log - (omit scope for cross-cutting changes)
-
Breaking: Does this break backward compatibility? If yes, add ! after scope.
审阅变更并确定:
-
类型:这属于哪种类型的变更?
- - 新功能或能力
feat - - 修复Bug
fix - - 仅文档变更
docs - - 代码重构,无行为变更
refactor - - 添加或更新测试
test - - 维护工作、依赖更新
chore - - 性能优化
perf - - CI/CD相关变更
ci
-
范围:哪个组件受到影响?
- 检查变更的文件,确定合适的范围
- 在项目内使用一致的范围名称(可查看寻找模式)
git log - (跨模块变更可省略范围)
-
破坏性:是否破坏向后兼容性?如果是,在范围后添加**!**。
Step 3: Write Commit Message
步骤3:编写提交信息
Format:
type(scope): description
[optional body explaining why, not what]
[optional footer with issue references]Rules:
- Use imperative mood: "add feature" not "added feature"
- Keep first line under 72 characters
- Focus on why in the body, the diff shows what
- Reference issues: or
Closes #123Fixes #456
格式:
type(scope): description
[可选正文,解释原因而非内容]
[可选页脚,包含问题引用]规则:
- 使用祈使语气:"add feature" 而非 "added feature"
- 第一行不超过72个字符
- 正文聚焦于原因,diff会展示内容
- 引用问题:或
Closes #123Fixes #456
Step 4: Stage, Commit, and Push
步骤4:暂存、提交与推送
bash
undefinedbash
undefinedStage all changes (or selectively stage)
暂存所有变更(或选择性暂存)
git add -A
git add -A
Commit with message (use HEREDOC for multi-line)
使用多行信息提交(使用HEREDOC)
git commit -m "$(cat <<'EOF'
type(scope): description
Optional body explaining the motivation.
Closes #123
Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
git commit -m "$(cat <<'EOF'
type(scope): description
Optional body explaining the motivation.
Closes #123
Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
Push to remote
推送至远程仓库
git push
undefinedgit push
undefinedExamples
示例
bash
undefinedbash
undefinedSimple feature
简单功能提交
git commit -m "feat(api): add pagination support to list endpoints"
git commit -m "feat(api): add pagination support to list endpoints"
Bug fix with body
带正文的Bug修复提交
git commit -m "$(cat <<'EOF'
fix(auth): handle token expiration during long requests
The previous implementation did not account for tokens expiring
during the processing of long-running requests.
Fixes #42
Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
git commit -m "$(cat <<'EOF'
fix(auth): handle token expiration during long requests
The previous implementation did not account for tokens expiring
during the processing of long-running requests.
Fixes #42
Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
Breaking change
破坏性变更提交
git commit -m "$(cat <<'EOF'
feat!(api): change response format for user endpoints
BREAKING CHANGE: The field is now an object with and
properties instead of a plain string.
statusstatemessageGenerated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
undefinedgit commit -m "$(cat <<'EOF'
feat!(api): change response format for user endpoints
BREAKING CHANGE: The field is now an object with and
properties instead of a plain string.
statusstatemessageGenerated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
EOF
)"
undefinedStep 5: Verify
步骤5:验证
After pushing, run to confirm the working tree is clean and the branch is up to date with remote.
git status推送完成后,运行确认工作树干净,且本地分支与远程分支保持同步。
git status