manage-git-branches
О программе
Этот навык Claude помогает разработчикам управлять ветками Git для создания функциональностей, переключения контекстов и поддержания синхронизации веток. Он охватывает именование веток, безопасное переключение с использованием stash, синхронизацию с вышестоящим репозиторием и очистку слитых веток. Используйте его при начале новой работы, переключении задач или поддержании порядка в ветках после слияний.
Быстрая установка
Claude Code
Рекомендуетсяnpx 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-branchesСкопируйте и вставьте эту команду в Claude Code для установки этого навыка
Документация
Manage Git Branches
Create, switch, sync, and clean up branches following consistent naming conventions.
When to Use
- Starting work on a new feature or bug fix
- Switching between tasks on different branches
- Keeping a feature branch up to date with main
- Cleaning up branches after merging pull requests
- Listing and inspecting branches
Inputs
- Required: Repository with at least one commit
- Optional: Branch naming convention (default:
type/description) - Optional: Base branch for new branches (default:
main) - Optional: Remote name (default:
origin)
Procedure
Step 1: Create a Feature Branch
Use a consistent naming convention:
| Prefix | Purpose | Example |
|---|---|---|
feature/ | New functionality | feature/add-weighted-mean |
fix/ | Bug fix | fix/null-pointer-in-parser |
docs/ | Documentation | docs/update-api-reference |
refactor/ | Code restructuring | refactor/extract-validation |
chore/ | Maintenance | chore/update-dependencies |
test/ | Test additions | 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
Got: New branch created and checked out. git branch shows the new branch with an asterisk.
If fail: If the base branch doesn't exist locally, fetch first: git fetch origin main && git checkout -b feature/name origin/main.
Step 2: Track Remote Branches
Set up tracking when pushing a new branch for the first time:
# Push and set upstream tracking
git push -u origin feature/add-weighted-mean
# Check tracking relationship
git branch -vv
To check out a remote branch that someone else created:
git fetch origin
git checkout feature/their-branch
# Git auto-creates a local tracking branch
Got: Local branch tracks the corresponding remote branch. git branch -vv shows the upstream.
If fail: If auto-tracking fails, set it manually: git branch --set-upstream-to=origin/feature/name feature/name.
Step 3: Switch Branches Safely
Before switching, ensure the working tree is clean:
# Check for uncommitted changes
git status
If changes exist, either commit or stash them:
# 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 and manage stashes:
# 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}
Got: Branch switch succeeds. Working tree reflects the target branch's state. Stashed changes are recoverable.
If fail: If switch is blocked by uncommitted changes that would be overwritten, stash or commit first. git stash cannot stash untracked files unless you use git stash push -u.
Step 4: Sync with Upstream
Keep your feature branch up to date with the base branch:
# 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
Got: Branch now includes the latest changes from main. No conflicts, or conflicts resolved (see resolve-git-conflicts).
If fail: If rebase causes conflicts, resolve each one and git rebase --continue. If the conflicts are too complex, abort with git rebase --abort and try git merge origin/main instead.
Step 5: Clean Up Merged Branches
After pull requests are merged, remove stale branches:
# 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
Got: Merged branches are removed locally and remotely. git branch shows only active branches.
If fail: git branch -d refuses to delete unmerged branches. If the branch was merged via squash merge on GitHub, Git may not recognize it as merged. Use git branch -D if you are certain the work is preserved.
Step 6: List and Inspect Branches
# 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
Got: Clear view of all branches, their status, and tracking relationships.
If fail: If remote branches appear stale, run git fetch --prune to clean up references to deleted remote branches.
Validation
- Branch names follow the agreed naming convention
- Feature branches are created from the correct base branch
- Local branches track their remote counterparts
- Merged branches are cleaned up (local and remote)
- Working tree is clean before branch switches
- Stashed changes are not left orphaned
Pitfalls
- Working on main directly: Always create a feature branch. Committing directly to main makes it difficult to create PRs and collaborate.
- Forgetting to fetch before branching: Creating a branch from a stale local main means you start behind. Always
git fetch originfirst. - Long-lived branches: Feature branches that live for weeks accumulate merge conflicts. Sync frequently and keep branches short-lived.
- Orphaned stashes:
git stashis temporary storage. Don't rely on it for long-term work. Commit or branch instead. - Deleting unmerged work:
git branch -Dis destructive. Double-check withgit log branch-namebefore force-deleting. - Not pruning: Remote branches deleted on GitHub still appear locally until you
git fetch --prune.
Related Skills
commit-changes- committing work on branchescreate-pull-request- opening PRs from feature branchesresolve-git-conflicts- handling conflicts during syncconfigure-git-repository- repository setup and branch strategy
GitHub репозиторий
Frequently asked questions
What is the manage-git-branches skill?
manage-git-branches is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform manage-git-branches-related tasks without extra prompting.
How do I install manage-git-branches?
Use the install commands on this page: add manage-git-branches to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does manage-git-branches belong to?
manage-git-branches is in the Meta category, tagged ai.
Is manage-git-branches free to use?
Yes. manage-git-branches is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.
Похожие навыки
Этот навык предоставляет проверенную в продакшене настройку для Content Collections — TypeScript-ориентированного инструмента, который преобразует файлы Markdown/MDX в типобезопасные коллекции данных с валидацией Zod. Используйте его при создании блогов, сайтов документации или контентных приложений на Vite + React для обеспечения типобезопасности и автоматической проверки содержимого. Он охватывает всё: от настройки плагина Vite и компиляции MDX до оптимизации развертывания и валидации схем.
Этот навык позволяет разработчикам создавать приложения на платформе прогнозных рынков Polymarket, включая интеграцию с API для торговли и получения рыночных данных. Он также обеспечивает потоковую передачу данных в реальном времени через WebSocket для отслеживания текущих сделок и рыночной активности. Используйте его для реализации торговых стратегий или создания инструментов, обрабатывающих обновления рынка в реальном времени.
Этот навык помогает разработчикам создавать плагины OpenCode, которые подключаются к более чем 25 типам событий, таким как команды, файлы и операции LSP. Он предоставляет структуру плагина, спецификации API событий и шаблоны реализации для модулей на JavaScript/TypeScript. Используйте его, когда вам нужно перехватывать, отслеживать или расширять жизненный цикл ассистента OpenCode AI с помощью пользовательской событийно-ориентированной логики.
SGLang — это высокопроизводительный фреймворк для обслуживания больших языковых моделей (LLM), специализирующийся на быстрой структурированной генерации JSON, regex и рабочих процессов агентов с использованием кэширования префиксов RadixAttention. Он обеспечивает значительно более высокую скорость вывода, особенно для задач с повторяющимися префиксами, что делает его идеальным для сложных структурированных результатов и многократных диалогов. Выбирайте SGLang вместо альтернатив, таких как vLLM, когда вам требуется ограниченное декодирование или вы создаете приложения с интенсивным совместным использованием префиксов.
