cp
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit & 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 messagebash
/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 contextbash
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:
| Prefix | Use Case |
|---|---|
| New feature |
| Bug fix |
| Documentation |
| Code restructuring |
| Formatting (no logic change) |
| Adding tests |
| Maintenance tasks |
如果未提供提交信息,则分析变更并生成符合Conventional Commits规范的信息:
| 前缀 | 使用场景 |
|---|---|
| 新功能 |
| 修复Bug |
| 文档更新 |
| 代码重构 |
| 格式调整(无逻辑变更) |
| 添加测试 |
| 维护任务 |
3. Stage Files
3. 暂存文件
Prefer specific files over :
git add -Abash
git add src/component.tsx src/utils.tsNever stage:
- files
.env - Credentials or secrets
- Large binary files (unless intentional)
优先暂存特定文件而非使用:
git add -Abash
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:
- No secrets: Scan for API keys, passwords, tokens
- Correct branch: Verify not pushing to protected branch accidentally
- Clean diff: Review what's being committed
提交前:
- 无机密信息:扫描是否存在API密钥、密码、令牌
- 正确的分支:确认不会意外推送到受保护分支
- 清晰的差异:检查即将提交的内容
Error Handling
错误处理
| Error | Solution |
|---|---|
| "Nothing to commit" | No changes detected, inform user |
| "Push rejected" | Run |
| "Pre-commit hook failed" | Fix issues, stage again, create NEW commit |
| 错误 | 解决方案 |
|---|---|
| "Nothing to commit" | 未检测到变更,告知用户 |
| "Push rejected" | 先执行 |
| "Pre-commit hook failed" | 修复问题,重新暂存,创建新的提交 |