← ClaudeAtlas

git-workflowlisted

【Git工作流】一键完成 Git 工作流:分支→暂存→commit→push→PR。 触发时机:用户说"帮我提PR"、"提交代码"、"git flow"。 智能判断 git 状态,自动执行需要的步骤。
afine907/skills · ★ 0 · AI & Automation · score 75
Install: claude install-skill afine907/skills
# Git Workflow — 一键 Git 工作流 自动化 Git 工作流:分支 → 暂存 → commit → push → PR。 ## Goal 一键完成 Git 工作流:智能判断状态 → 创建分支 → 暂存 → commit → push → PR。 ## Trigger 用户说出以下任一关键词时触发: - 帮我提 PR、提交代码、推一下 - 创建分支然后提交、git flow - 提交并推送、一键提交 - 发 PR、开 PR ## 工作流程 ``` 智能判断 git 状态 → 执行需要的步骤 → 完成 ``` ### Step 1: 智能判断当前状态 ```bash # 检查是否在 git 仓库 git rev-parse --is-inside-work-tree # 获取当前分支 git rev-parse --abbrev-ref HEAD # 检查工作区状态 git status --porcelain # 检查暂存区 git diff --staged --name-only # 检查未提交的变更 git diff --name-only # 检查是否有未推送的 commit git log origin/main..HEAD --oneline 2>/dev/null || git log origin/master..HEAD --oneline 2>/dev/null ``` **根据状态决定执行步骤**: | 当前状态 | 执行步骤 | |----------|----------| | 在 main/master 分支,有未暂存变更 | 1. 创建分支 → 2. 暂存 → 3. commit → 4. push → 5. PR | | 在 feature 分支,有未暂存变更 | 2. 暂存 → 3. commit → 4. push → 5. PR | | 在 feature 分支,有未提交 commit | 4. push → 5. PR | | 在 main/master 分支,无变更 | 1. 创建分支(等用户描述需求) | | 已推送,无新 commit | 无操作,提示"已是最新的" | ### Step 2: 创建/切换分支(如需要) **分支命名规则**(Conventional Commits 前缀): | 需求类型 | 前缀 | 示例 | |----------|------|------| | 新功能 | `feat/` | `feat/user-auth` | | Bug 修复 | `fix/` | `fix/login-error` | | 重构 | `refactor/` | `refactor/api-layer` | | 文档 | `docs/` | `docs/api-guide` | | 测试 | `test/` | `test/auth-cases` | | 构建/CI | `chore/` | `chore/ci-config` | **自动推断逻辑**: - 用户描述中包含"修复"、"bug"、"fix" → `fix/xxx` - 用户描述中包含"新增"、"添加"、"feat" → `feat/xxx` - 其他情况 → 根据变更内容推断 **执行命令**: ```bash # 创建并