cp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit & Push Skill

提交与推送Skill

Streamlined git workflow: stage, commit, and push in one command.
简化Git工作流:通过一条命令完成暂存、提交与推送。

Usage

使用方法

Basic

基础用法

bash
/cp                        # Auto-generate commit message
/cp "fix: resolve bug"     # Use provided message
bash
/cp                        # 自动生成提交信息
/cp "fix: 修复Bug"     # 使用指定的提交信息

Korean Triggers

韩语触发词

  • "커밋하고 푸시"
  • "커밋 푸시"
  • "변경사항 올려줘"
  • "커밋하고 푸시"
  • "커밋 푸시"
  • "帮我上传变更内容"

Workflow

工作流程

1. Analyze Changes

1. 分析变更

bash
git status                 # See all changes
git diff --staged          # Staged changes
git diff                   # Unstaged changes
git log -3 --oneline       # Recent commits for context
bash
git status                 # 查看所有变更
git diff --staged          # 已暂存的变更
git diff                   # 未暂存的变更
git log -3 --oneline       # 最近3条提交记录以获取上下文

2. Generate Commit Message

2. 生成提交信息

If no message provided, analyze changes and generate following Conventional Commits:
PrefixUse Case
feat:
New feature
fix:
Bug fix
docs:
Documentation
refactor:
Code restructuring
style:
Formatting (no logic change)
test:
Adding tests
chore:
Maintenance tasks
如果未提供提交信息,则分析变更并生成符合Conventional Commits规范的信息:
前缀使用场景
feat:
新功能
fix:
修复Bug
docs:
文档更新
refactor:
代码重构
style:
格式调整(无逻辑变更)
test:
添加测试
chore:
维护任务

3. Stage Files

3. 暂存文件

Prefer specific files over
git add -A
:
bash
git add src/component.tsx src/utils.ts
Never stage:
  • .env
    files
  • Credentials or secrets
  • Large binary files (unless intentional)
优先暂存特定文件而非使用
git add -A
bash
git add src/component.tsx src/utils.ts
绝对不要暂存:
  • .env
    文件
  • 凭证或机密信息
  • 大型二进制文件(除非是有意为之)

4. Commit

4. 提交

Use HEREDOC for proper formatting:
bash
git commit -m "$(cat <<'EOF'
type: concise description

Optional body with more details.

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
使用HEREDOC来保证格式正确:
bash
git commit -m "$(cat <<'EOF'
type: 简洁描述

可选的详细描述内容。

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"

5. Push

5. 推送

bash
git push origin <current-branch>
If upstream not set:
bash
git push -u origin <current-branch>
bash
git push origin <current-branch>
如果未设置上游分支:
bash
git push -u origin <current-branch>

Safety Checks

安全检查

Before committing:
  1. No secrets: Scan for API keys, passwords, tokens
  2. Correct branch: Verify not pushing to protected branch accidentally
  3. Clean diff: Review what's being committed
提交前:
  1. 无机密信息:扫描是否存在API密钥、密码、令牌
  2. 正确的分支:确认不会意外推送到受保护分支
  3. 清晰的差异:检查即将提交的内容

Error Handling

错误处理

ErrorSolution
"Nothing to commit"No changes detected, inform user
"Push rejected"Run
git pull
first, then retry
"Pre-commit hook failed"Fix issues, stage again, create NEW commit
错误解决方案
"Nothing to commit"未检测到变更,告知用户
"Push rejected"先执行
git pull
,然后重试
"Pre-commit hook failed"修复问题,重新暂存,创建新的提交