manage-git-branches
About
This Claude Skill helps developers manage Git branches for feature work and maintenance. It handles creating, switching, syncing, and cleaning branches, including safe switching with stash and upstream synchronization. Use it when starting new features, switching tasks, updating branches with main, or pruning merged branches.
Quick Install
Claude Code
Recommendednpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/manage-git-branchesCopy and paste this command in Claude Code to install this skill
Documentation
管 Git 支
造、追、換、同、清諸支循一致命約。
用
- 啟新功或錯修工
- 於異支間切任
- 保功支與 main 同
- PR 合後清支
- 列並察支
入
- 必:至少一提交之庫
- 可:支命約(默
type/description) - 可:新支之基支(默
main) - 可:遠名(默
origin)
行
一:造功支
用一致命約:
| 前綴 | 目 | 例 |
|---|---|---|
feature/ | 新功 | feature/add-weighted-mean |
fix/ | 錯修 | fix/null-pointer-in-parser |
docs/ | 文 | docs/update-api-reference |
refactor/ | 重構 | refactor/extract-validation |
chore/ | 維護 | chore/update-dependencies |
test/ | 測 | test/add-edge-case-coverage |
# Create and switch to a new branch from main
git checkout -b feature/add-weighted-mean main
# Or using the newer switch command
git switch -c feature/add-weighted-mean main
得:新支造並檢出。git branch 示新支附星。
敗:基支於本無→先取:git fetch origin main && git checkout -b feature/name origin/main。
二:追遠支
首推新支時立追:
# Push and set upstream tracking
git push -u origin feature/add-weighted-mean
# Check tracking relationship
git branch -vv
檢出他人造之遠支:
git fetch origin
git checkout feature/their-branch
# Git auto-creates a local tracking branch
得:本支追對應遠支。git branch -vv 示上游。
敗:自動追敗→手設:git branch --set-upstream-to=origin/feature/name feature/name。
三:安換支
換前確工樹淨:
# Check for uncommitted changes
git status
有變→或提或藏:
# Option 1: Commit work in progress
git add <files>
git commit -m "wip: save progress on validation logic"
# Option 2: Stash changes temporarily
git stash push -m "validation work in progress"
# Switch branches
git checkout main
# Later, restore stashed changes
git checkout feature/add-weighted-mean
git stash pop
列並管藏:
# List all stashes
git stash list
# Apply a specific stash (without removing it)
git stash apply stash@{1}
# Drop a stash
git stash drop stash@{0}
得:換成。工樹反目支態。藏可恢。
敗:換受未提變阻(會覆)→先藏或提。git stash 不能藏未追文件除非用 git stash push -u。
四:與上游同
保功支與基支同:
# Fetch latest changes
git fetch origin
# Rebase onto latest main (preferred — keeps linear history)
git rebase origin/main
# Or merge main into your branch (creates merge commit)
git merge origin/main
得:支含 main 之新變。無衝或衝已解(見 resolve-git-conflicts)。
敗:重定基生衝→解各並 git rebase --continue。衝過複→以 git rebase --abort 棄並試 git merge origin/main。
五:清已合支
PR 合後除陳支:
# Delete a local branch that has been merged
git branch -d feature/add-weighted-mean
# Delete a local branch (force, even if not merged)
git branch -D feature/abandoned-experiment
# Delete a remote branch
git push origin --delete feature/add-weighted-mean
# Prune remote-tracking references for deleted remote branches
git fetch --prune
得:已合支本地與遠除。git branch 僅示活支。
敗:git branch -d 拒刪未合支。若 GitHub 以擠合→Git 或不識為已合。若確工已保→用 git branch -D。
六:列並察支
# List local branches
git branch
# List all branches (local and remote)
git branch -a
# List branches with last commit info
git branch -v
# List branches merged into main
git branch --merged main
# List branches NOT yet merged
git branch --no-merged main
# See which remote branch each local branch tracks
git branch -vv
得:諸支之明視、其態、追關係。
敗:遠支似陳→運 git fetch --prune 清除已刪遠支之引。
驗
- 支名循約
- 功支由正基支造
- 本支追其遠對應
- 已合支清(本與遠)
- 換支前工樹淨
- 藏變無孤留
忌
- 直工 main:必造功支。直提 main 難造 PR 與協作
- 分支前忘取:由陳本 main 造支→始落。必先
git fetch origin - 長命支:持週之功支積合衝。常同並保短命
- 孤藏:
git stash乃臨存。勿賴之為長期工。改提或分支 - 刪未合工:
git branch -D為毀。強刪前以git log branch-name複核 - 不剪:GitHub 已刪遠支於本地仍現至運
git fetch --prune
參
commit-changes- 支上工提交create-pull-request- 由功支開 PRresolve-git-conflicts- 同時處衝configure-git-repository- 庫設與支策
GitHub Repository
Related Skills
content-collections
MetaThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
polymarket
MetaThis skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.
creating-opencode-plugins
MetaThis skill helps developers create OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It provides the plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript modules. Use it when you need to intercept, monitor, or extend the OpenCode AI assistant's lifecycle with custom event-driven logic.
sglang
MetaSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
