git-worktrees
БесплатноБез исполняемых скриптовНе проверенUse git worktrees for parallel development on multiple branches simultaneously
от bobmatnyc★ 79 звёзд на GitHubОб этом скилле
Git Worktrees
Overview
Git worktrees allow you to have multiple working directories from the same repository, each with a different branch checked out. Work on multiple branches simultaneously without switching.
When to Use Worktrees
✅ Perfect For:
- Stacked PR development (one worktree per PR)
- Urgent hotfix while working on feature
- Parallel development on multiple features
- Code review in isolation
- Testing cross-branch interactions
- Running multiple dev servers simultaneously
⚠️ Consider Alternatives When:
- Limited disk space (worktrees duplicate working directory)
- Simple branch switching is sufficient
- Only working on one branch at a time
Basic Workflow
Create Worktree
New Branch:
# Create worktree with new branch
git worktree add ../worktrees/feature-auth -b feature/authentication
# Navigate to worktree
cd ../worktrees/feature-auth
Existing Branch:
# Create worktree from existing remote branch
git worktree add ../worktrees/feature-profile feature/user-profile
# Or from origin
git worktree add ../worktrees/review origin/feature/pr-to-review
List Worktrees
git worktree list
# Output:
# /Users/dev/project abc123 [main]
# /Users/dev/worktrees/f-auth def456 [feature/authentication]
# /Users/dev/worktrees/f-profile ghi789 [feature/user-profile]
Remove Worktree
# Remove worktree (deletes directory)
git worktree remove ../worktrees/feature-auth
# Or manually delete directory and prune
rm -rf ../worktrees/feature-auth
git worktree prune
Directory Structure
Recommended layout:
/Users/dev/
├── my-project/ # Main repository
│ ├── .git/ # Git database
│ ├── src/
│ └── ...
└── my-project-worktrees/ # All worktrees here
├── feature-auth/ # feature/authentication branch
├── feature-profile/ # feature/user-profile branch
├── hotfix-urgent/ # hotfix/urgent-fix branch
└── review-pr-123/ # Reviewing PR #123
Use Case: Stacked PRs
Perfect for stacked PR workflow - one worktree per PR:
# Create worktree for each PR in stack
git worktree add ../stack/pr-001 -b feature/001-base-auth
git worktree add ../stack/pr-002 -b feature/002-user-profile
git worktree add ../stack/pr-003 -b feature/003-admin-panel
# Work in each independently
cd ../stack/pr-001
# Implement base auth
git commit -am "feat: base authentication"
git push -u origin feature/001-base-auth
cd ../stack/pr-002
# Already on feature/002-user-profile branch
# Implement user profile (depends on pr-001)
git commit -am "feat: user profile with auth"
git push -u origin feature/002-user-profile
cd ../stack/pr-003
# Implement admin panel (depends on pr-002)
git commit -am "feat: admin panel"
git push -u origin feature/003-admin-panel
Use Case: Parallel Development
Run multiple dev servers simultaneously:
# Terminal 1: Main feature development
cd /project-worktrees/feature-new-ui
npm install
npm run dev # Server on port 3000
# Terminal 2: Urgent hotfix (different branch)
cd /project-worktrees/hotfix-critical
npm install
npm run dev -- --port 3001 # Server on port 3001
# Both running simultaneously without branch switching
Use Case: Code Review
Review PRs in isolation:
# Create worktree for PR review
git worktree add ../review/pr-456 origin/feature/user-auth
cd ../review/pr-456
npm install
npm test
npm run dev
# Review code, test functionality
# When done, remove worktree
cd /main-project
git worktree remove ../review/pr-456
Updating Stacked PRs with Worktrees
When base PR changes, update chain across worktrees:
# PR-001 got feedback
cd /stack/pr-001
git pull origin feature/001-base-auth
# Make changes, push
# Update PR-002 (in separate worktree)
cd /stack/pr-002
git rebase feature/001-base-auth
git push --force-with-lease origin feature/002-user-profile
# Update PR-003 (in separate worktree)
cd /stack/pr-003
git rebase feature/002-user-profile
git push --force-with-lease origin feature/003-admin-panel
Managing Dependencies
Shared node_modules (Save Disk Space)
Option 1: Symlink
cd /worktrees/feature-auth
ln -s /main-project/node_modules node_modules
Option 2: Separate Install
cd /worktrees/feature-auth
npm install # Independent node_modules
Trade-off:
- Symlink: Less disk space, may have version conflicts
- Separate: More disk space, guaranteed isolation
Best Practices
1. Naming Convention
# Use descriptive, consistent names
git worktree add ../worktrees/feature-authentication feature/authentication
git worktree add ../worktrees/hotfix-security hotfix/security-patch
2. Location Strategy
# Keep worktrees outside main repo
/Users/dev/project/ # Main repo (never delete)
/Users/dev/project-worktrees/ # All worktrees here (safe to delete)
3. Cleanup Discipline
# When PR merged
Установить git-worktrees в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл git-worktrees?
Use git worktrees for parallel development on multiple branches simultaneously
Как установить скилл git-worktrees?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл git-worktrees запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic