MCP HubMCP Hub
Volver a habilidades

manage-git-branches

pjt222
Actualizado 2 days ago
7 vistas
17
2
17
Ver en GitHub
Metaai

Acerca de

Esta Habilidad de Claude ayuda a los desarrolladores a gestionar ramas de Git para características, correcciones y limpieza. Maneja la creación, el cambio, la sincronización con el repositorio principal y la poda de ramas fusionadas utilizando prácticas seguras como el almacenamiento temporal (stashing). Úsala al comenzar un nuevo trabajo, cambiar de tarea o mantener las ramas actualizadas con la rama principal.

Instalación rápida

Claude Code

Recomendado
Principal
npx skills add pjt222/agent-almanac -a claude-code
Comando PluginAlternativo
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternativo
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/manage-git-branches

Copia y pega este comando en Claude Code para instalar esta habilidad

Documentación

Manage Git Branches

Create, switch, sync, clean up branches per consistent naming.

Use When

  • Start new feature / bug fix
  • Switching tasks on diff branches
  • Keep feature branch up-to-date w/ main
  • Clean up after merging PRs
  • List + inspect branches

In

  • Req: Repo w/ ≥1 commit
  • Opt: Naming convention (default: type/description)
  • Opt: Base branch (default: main)
  • Opt: Remote name (default: origin)

Do

Step 1: Create Feature Branch

Consistent naming:

PrefixPurposeExample
feature/New functionalityfeature/add-weighted-mean
fix/Bug fixfix/null-pointer-in-parser
docs/Documentationdocs/update-api-reference
refactor/Code restructuringrefactor/extract-validation
chore/Maintenancechore/update-dependencies
test/Test additionstest/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

→ New branch created + checked out. git branch shows branch w/ asterisk.

If err: Base branch doesn't exist locally → fetch first: git fetch origin main && git checkout -b feature/name origin/main.

Step 2: Track Remote Branches

Setup tracking when pushing new branch first time:

# Push and set upstream tracking
git push -u origin feature/add-weighted-mean

# Check tracking relationship
git branch -vv

Check out remote branch someone else created:

git fetch origin
git checkout feature/their-branch
# Git auto-creates a local tracking branch

→ Local tracks remote. git branch -vv shows upstream.

If err: Auto-tracking fails → manually: git branch --set-upstream-to=origin/feature/name feature/name.

Step 3: Switch Branches Safely

Before switch → working tree clean:

# Check for uncommitted changes
git status

Changes exist → commit or stash:

# 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 + 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}

→ Switch succeeds. Working tree reflects target. Stashed changes recoverable.

If err: Switch blocked by uncommitted changes → stash or commit first. git stash can't stash untracked files unless git stash push -u.

Step 4: Sync w/ Upstream

Keep feature branch up-to-date w/ base:

# 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

→ Branch has latest from main. No conflicts, or resolved (see resolve-git-conflicts).

If err: Rebase conflicts → resolve each + git rebase --continue. Too complex → abort w/ git rebase --abort + try git merge origin/main.

Step 5: Clean Up Merged Branches

After PRs merged → remove stale:

# 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

→ Merged branches removed locally + remotely. git branch shows only active.

If err: git branch -d refuses unmerged. If merged via squash merge on GitHub → Git may not recognize as merged. Use git branch -D if certain work preserved.

Step 6: List + Inspect

# 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

→ Clear view of all branches, status, tracking.

If err: Remote branches appear stale → git fetch --prune → clean up refs to deleted remotes.

Check

  • Branch names follow agreed convention
  • Feature branches from correct base
  • Local branches track remotes
  • Merged cleaned up (local + remote)
  • Working tree clean before switches
  • Stashes not left orphaned

Traps

  • Work on main directly: Always create feature branch. Committing directly to main → hard to create PRs + collaborate.
  • Forget fetch before branching: Creating from stale local main → start behind. Always git fetch origin first.
  • Long-lived branches: Weeks-long → accumulate conflicts. Sync freq + keep short-lived.
  • Orphaned stashes: git stash = temporary storage. Don't rely for long-term. Commit / branch instead.
  • Delete unmerged work: git branch -D destructive. Double-check w/ git log branch-name before force-delete.
  • Not pruning: Remote branches deleted on GitHub still appear locally until git fetch --prune.

  • commit-changes — committing work on branches
  • create-pull-request — opening PRs from feature branches
  • resolve-git-conflicts — handling conflicts during sync
  • configure-git-repository — repo setup + branch strategy

Repositorio GitHub

pjt222/agent-almanac
Ruta: i18n/caveman-ultra/skills/manage-git-branches
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Habilidades relacionadas

content-collections

Meta

Esta habilidad proporciona una configuración probada en producción para Content Collections, una herramienta centrada en TypeScript que transforma archivos Markdown/MDX en colecciones de datos con tipado seguro mediante validación Zod. Úsala al construir blogs, sitios de documentación o aplicaciones Vite + React con mucho contenido para garantizar seguridad de tipos y validación automática de contenido. Abarca todo, desde la configuración del plugin de Vite y compilación MDX hasta la optimización de despliegue y validación de esquemas.

Ver habilidad

polymarket

Meta

Esta habilidad permite a los desarrolladores crear aplicaciones con la plataforma de mercados de predicción Polymarket, incluyendo la integración de API para operaciones y datos de mercado. También proporciona transmisión de datos en tiempo real a través de WebSocket para monitorear operaciones en vivo y actividad del mercado. Úsela para implementar estrategias de trading o crear herramientas que procesen actualizaciones de mercado en tiempo real.

Ver habilidad

creating-opencode-plugins

Meta

Esta habilidad ayuda a los desarrolladores a crear complementos de OpenCode que se conectan a más de 25 tipos de eventos, como comandos, archivos y operaciones LSP. Proporciona la estructura del complemento, las especificaciones de la API de eventos y los patrones de implementación para módulos en JavaScript/TypeScript. Úsala cuando necesites interceptar, monitorear o extender el ciclo de vida del asistente de IA de OpenCode con lógica personalizada basada en eventos.

Ver habilidad

sglang

Meta

SGLang es un framework de alto rendimiento para el servicio de LLM que se especializa en generación rápida y estructurada para JSON, expresiones regulares y flujos de trabajo de agentes utilizando su caché de prefijos RadixAttention. Ofrece una inferencia significativamente más rápida, especialmente para tareas con prefijos repetidos, lo que lo hace ideal para salidas complejas y estructuradas, y conversaciones multiturno. Elige SGLang sobre alternativas como vLLM cuando necesites decodificación restringida o estés construyendo aplicaciones con uso extensivo de prefijos compartidos.

Ver habilidad