Loading...
Loading...
Gestiona git worktrees en .worktrees/. Usa cuando el usuario diga "crear worktree", "nuevo branch en paralelo", "trabajar en otra feature", "limpiar worktrees", "listar worktrees", o quiera desarrollo paralelo sin cambiar de branch.
npx skill4agent add testacode/llm-toolkit worktree-manager.worktrees/~/Projects/<github|gitlab>/<project>/
├── .worktrees/ # ignorado por .gitignore
│ ├── feature-x/ # worktree para branch feature-x
│ └── bugfix-123/ # worktree para branch bugfix-123
├── src/ # archivos del repo (master/main)
└── .gitignore # debe incluir .worktrees/# Verificar que es un repo git
git rev-parse --is-inside-work-tree
# Verificar rama actual (debe ser main o master para operaciones desde root)
git branch --show-current# Verificar si .worktrees/ esta en .gitignore
grep -q "^\.worktrees/$" .gitignore 2>/dev/null || echo ".worktrees/" >> .gitignore
# Crear carpeta .worktrees si no existe
mkdir -p .worktrees
# Verificar estado
cat .gitignore | grep worktrees.worktrees/.gitignoregit add .gitignore
git commit -m "chore: ignore worktrees folder"# Sintaxis: git worktree add .worktrees/<nombre-branch> -b <nombre-branch>
git worktree add .worktrees/feature-nueva-funcionalidad -b feature-nueva-funcionalidadfeature/<descripcion>feature-<descripcion>bugfix/<descripcion>bugfix-<descripcion>hotfix/<descripcion>chore/<descripcion>git worktree list/Users/user/Projects/github/mi-proyecto abc1234 [main]
/Users/user/Projects/github/mi-proyecto/.worktrees/feature-x def5678 [feature-x]cd .worktrees/<nombre-branch>
# Trabajar normalmente...
# hacer cambios...
# Commit y push
git add .
git commit -m "feat: descripcion del cambio"
git push -u origin <nombre-branch># Desde el directorio raiz del proyecto (no desde el worktree)
# Paso 1: Remover worktree
git worktree remove .worktrees/<nombre-branch>
# Paso 2: Eliminar branch remoto (si no se elimino con el PR)
git push origin --delete <nombre-branch>
# Paso 3: Eliminar branch local si existe
git branch -d <nombre-branch>git worktree prune# 1. Asegurar que estamos en main/master actualizado
git checkout main
git pull origin main
# 2. Verificar setup (primera vez)
grep -q "^\.worktrees/$" .gitignore || echo ".worktrees/" >> .gitignore
# 3. Crear worktree para la feature
git worktree add .worktrees/feature-auth -b feature-auth
# 4. Ir al worktree
cd .worktrees/feature-auth
# 5. Desarrollar, commit, push
# ... hacer cambios ...
git add .
git commit -m "feat: add authentication module"
git push -u origin feature-auth
# 6. Crear PR (desde GitHub CLI o web)
gh pr create --title "feat: add authentication module" --body "..."
# 7. Despues del merge, volver al root y limpiar
cd ../.. # volver a raiz del proyecto
git worktree remove .worktrees/feature-auth
git push origin --delete feature-auth# Desde main actualizado
git pull origin main
# Crear worktree para el fix
git worktree add .worktrees/bugfix-login-error -b bugfix-login-error
# Trabajar en el fix
cd .worktrees/bugfix-login-error
# ... fix ...
git add . && git commit -m "fix: resolve login error on mobile"
git push -u origin bugfix-login-error
# Crear PR
gh pr create --title "fix: resolve login error" --body "..."
# Despues del merge
cd ../..
git worktree remove .worktrees/bugfix-login-error| Principio | Descripcion |
|---|---|
| Worktrees son temporales | No son casas permanentes, se eliminan despues del merge |
| Main siempre limpio | El repo principal siempre esta en main/master |
| Nombres descriptivos | Carpeta del worktree = nombre del branch |
| Cleanup obligatorio | Siempre limpiar despues del merge del PR |
git worktree list
ls -la .worktrees/# Opcion 1: Usar branch existente (sin -b)
git worktree add .worktrees/feature-x feature-x
# Opcion 2: Eliminar branch viejo primero
git branch -D feature-x
git worktree add .worktrees/feature-x -b feature-x# Ver donde esta el branch
git worktree list
# Remover el worktree anterior primero
git worktree remove .worktrees/<branch-name>git worktree removegit worktree prune
git worktree list # verificar que se limpiofeature-*bugfix-*.worktrees/.gitignore