.gemini/skills/git-workflow-guide/SKILL.md
[UDS] 指導 Git 分支策略、分支命名與合併操作
npx skillsauth add asiaostrich/universal-dev-standards git-flowInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
語言: English | 繁體中文
版本: 1.0.0 最後更新: 2025-12-24 適用範圍: Claude Code Skills
本技能提供 Git 分支策略、分支命名慣例與合併操作的指導。
| 部署頻率 | 建議策略 | |---------|---------| | 每日多次 | Trunk-Based Development | | 每週至雙週 | GitHub Flow | | 每月或更長 | GitFlow |
<type>/<short-description>
| 類型 | 用途 | 範例 |
|------|------|------|
| feature/ | 新功能 | feature/oauth-login |
| fix/ 或 bugfix/ | 錯誤修復 | fix/memory-leak |
| hotfix/ | 緊急生產環境修復 | hotfix/security-patch |
| refactor/ | 程式碼重構 | refactor/extract-service |
| docs/ | 僅文件變更 | docs/api-reference |
| test/ | 測試新增 | test/integration-tests |
| chore/ | 維護任務 | chore/update-dependencies |
| release/ | 發布準備 | release/v1.2.0 |
完整標準請參閱:
建立新分支前:
檢查未合併的分支
git branch --no-merged main
同步最新程式碼
git checkout main
git pull origin main
驗證測試通過
npm test # 或您專案的測試指令
使用正確命名建立分支
git checkout -b feature/description
| 策略 | 使用時機 |
|------|---------|
| Merge Commit (--no-ff) | 長期功能、GitFlow 發布 |
| Squash Merge | 功能分支、乾淨歷史 |
| Rebase + FF | Trunk-Based、短期分支 |
# 良好範例
git checkout -b feature/user-authentication
git checkout -b fix/null-pointer-in-payment
git checkout -b hotfix/critical-data-loss
# 不良範例
git checkout -b 123 # 缺乏描述性
git checkout -b Fix-Bug # 非小寫
git checkout -b myFeature # 缺少類型前綴
# 1. 從 main 建立分支
git checkout main
git pull origin main
git checkout -b feature/user-profile
# 2. 進行變更並提交
git add .
git commit -m "feat(profile): add avatar upload"
git push -u origin feature/user-profile
# 3. 透過 GitHub/GitLab UI 建立 PR 並合併
# 4. 合併後刪除分支
git checkout main
git pull origin main
git branch -d feature/user-profile
# 1. 使用 main 更新您的分支
git checkout feature/my-feature
git fetch origin
git merge origin/main
# 2. 在檔案中解決衝突
# <<<<<<< HEAD
# 您的變更
# =======
# 傳入的變更
# >>>>>>> origin/main
# 3. 暫存已解決的檔案
git add resolved-file.js
# 4. 完成合併
git commit -m "chore: resolve merge conflicts with main"
# 5. 測試並推送
npm test
git push origin feature/my-feature
本技能支援專案特定的工作流程組態。
CONTRIBUTING.md 是否有「Git Workflow」或「Branching Strategy」章節若未找到組態:
CONTRIBUTING.md 中記錄:## Git 工作流程
### 分支策略
本專案使用 **[所選選項]**。
### 分支命名
格式:`<type>/<description>`
範例:`feature/oauth-login`、`fix/memory-leak`
### 合併策略
- 功能分支:**[Squash / Merge commit / Rebase]**
| 版本 | 日期 | 變更 | |------|------|------| | 1.0.0 | 2025-12-24 | 新增:標準章節(目的、相關標準、版本歷史、授權) |
本技能採用 CC BY 4.0 授權發布。
來源:universal-dev-standards
development
[UDS] 扫描代码库的调试残留与代码质量问题;可自动修正安全模式。 Use when: before committing, during PR review, or periodic codebase cleanup. Keywords: sweep, debug cleanup, console.log, debugger, TODO, ts-any, code quality, 扫描, 清理.
tools
[UDS] 从规格衍生 BDD 场景、TDD 骨架或 ATDD 表格
development
[UDS] 识别重复流程并以正确的开发深度构建 Skill
tools
[UDS] AI 辅助 git push 安全层:质量门禁 + 协作护栏。 Use when: pushing commits, force pushing, pushing to protected branches, pushing feature branches. Keywords: git push, force push, protected branch, quality gate, push receipt, PR automation, 推送, 保护分支, 质量门禁.