git-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Workflow Automation
Git工作流自动化
Automated helpers for common git workflows and branch management tasks.
用于常见Git工作流和分支管理任务的自动化辅助工具。
No Setup Required
无需设置
This skill uses native git commands and bash scripts - no additional tools or SDKs needed. Works immediately in any environment with git installed.
本Skill使用原生Git命令和bash脚本——无需额外工具或SDK。在任何安装了Git的环境中均可立即使用。
Quick Start
快速开始
Create Feature Branch
创建功能分支
Create a new feature branch following naming conventions:
bash
undefined按照命名规范创建新的功能分支:
bash
undefinedInteractive: prompts for feature name
交互式:提示输入功能名称
cd /path/to/repo
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh
cd /path/to/repo
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh
Non-interactive: specify feature name
非交互式:指定功能名称
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh "add-user-auth"
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh "add-user-auth"
Creates: feature/add-user-auth
创建:feature/add-user-auth
undefinedundefinedClean Up Merged Branches
清理已合并分支
Remove local branches that have been merged to main/master:
bash
cd /path/to/repo删除已合并到main/master的本地分支:
bash
cd /path/to/repoPreview what would be deleted (dry run)
预览将被删除的内容(试运行)
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --dry-run
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --dry-run
Actually delete merged branches
实际删除已合并分支
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh
Force cleanup (skip confirmations)
强制清理(跳过确认)
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --force
undefinedbash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --force
undefinedInteractive Rebase Helper
交互式变基辅助工具
Simplified interactive rebase with common options:
bash
cd /path/to/repo简化的交互式变基,包含常见选项:
bash
cd /path/to/repoRebase last 3 commits
变基最近3次提交
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh 3
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh 3
Rebase since a specific commit
从特定提交开始变基
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh abc123
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh abc123
Rebase onto main
变基到main分支
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh main
undefinedbash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh main
undefinedAvailable Scripts
可用脚本
All scripts are located in the skill's directory and can be run with bash.
scripts/| Script | Purpose | Usage |
|---|---|---|
| Create feature branches with naming conventions | |
| Clean up merged branches | |
| Interactive rebase helper | |
所有脚本位于Skill的目录中,可通过bash运行。
scripts/| 脚本 | 用途 | 使用方法 |
|---|---|---|
| 按照命名规范创建功能分支 | |
| 清理已合并分支 | |
| 交互式变基辅助工具 | |
Workflow Examples
工作流示例
Starting a New Feature
启动新功能
bash
undefinedbash
undefined1. Ensure main is up to date
1. 确保main分支是最新的
git checkout main
git pull origin main
git checkout main
git pull origin main
2. Create feature branch
2. 创建功能分支
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh "user-authentication"
bash ~/.claude/skills/git-workflow/scripts/create-feature-branch.sh "user-authentication"
3. Work on feature...
3. 开发功能...
(make commits)
(提交代码)
4. Push when ready
4. 准备就绪后推送
git push -u origin feature/user-authentication
undefinedgit push -u origin feature/user-authentication
undefinedCleaning Up After PR Merge
PR合并后清理
bash
undefinedbash
undefined1. Update main branch
1. 更新main分支
git checkout main
git pull origin main
git checkout main
git pull origin main
2. Preview what will be deleted
2. 预览将被删除的内容
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --dry-run
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh --dry-run
3. Clean up merged branches
3. 清理已合并分支
bash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh
undefinedbash ~/.claude/skills/git-workflow/scripts/cleanup-merged-branches.sh
undefinedSquashing Commits Before PR
PR前压缩提交
bash
undefinedbash
undefinedSquash last 5 commits into one
将最近5次提交压缩为1次
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh 5
bash ~/.claude/skills/git-workflow/scripts/interactive-rebase.sh 5
In the editor that opens:
在打开的编辑器中:
- Change 'pick' to 'squash' (or 's') for commits 2-5
- 将第2-5次提交的'pick'改为'squash'(或's')
- Keep first commit as 'pick'
- 保留第一次提交为'pick'
- Save and close
- 保存并关闭
Then edit the combined commit message
然后编辑合并后的提交信息
undefinedundefinedSafety Features
安全特性
All scripts include:
- Dry run mode - Preview changes before applying
- Confirmation prompts - Ask before destructive operations
- Current branch protection - Won't delete the branch you're on
- Main/master protection - Won't delete main branches
- Uncommitted changes check - Warns if working directory is dirty
所有脚本包含:
- 试运行模式 - 应用更改前预览效果
- 确认提示 - 执行破坏性操作前询问确认
- 当前分支保护 - 不会删除你当前所在的分支
- Main/master分支保护 - 不会删除主分支
- 未提交更改检查 - 若工作目录有未提交更改则发出警告
Prerequisites
前置条件
- git - Installed and configured (available in most dev environments)
- bash - Standard shell (available on Linux, macOS, and Git Bash on Windows)
No additional tools, SDKs, or environment variables required.
- git - 已安装并配置(大多数开发环境中已预装)
- bash - 标准shell(在Linux、macOS和Windows的Git Bash中可用)
无需额外工具、SDK或环境变量。