mcpField
G
git-worktree-manager

git-worktree-manager

github.com/d-o-hubDevelopment1339 installsUpdated today
Repository

About git-worktree-manager

git-worktree-manager is a skill for managing Git worktrees, aimed at developers working across multiple branches. It covers worktree creation, listing, removal, and cleanup, with patterns for parallel testing and code review.

Key features

  1. 01Create worktrees from branches or commits
  2. 02List worktrees in readable formats
  3. 03Remove worktrees and prune metadata
  4. 04Lock and unlock worktrees
  5. 05Workflows for testing and review

Use cases

  1. 01Developing features alongside main work
  2. 02Testing multiple branches in parallel
  3. 03Reviewing a pull request in isolation
  4. 04Cleaning up merged or orphaned worktrees

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/d-o-hub/rust-self-learning-memory --skill git-worktree-manager

After installing, type/git-worktree-managerin Claude Code to confirm it loaded.

Details

From the project README

Git Worktree Manager

Manage git worktrees to enable parallel multi-branch development while keeping the main working directory clean.

Recommended Directory Structure

project/
├── main-repo/          # Main working directory
└── worktrees/          # All worktrees here
    ├── feature/name/
    ├── bugfix/name/
    └── experiment/name/

Core Commands

Create Worktree
# From existing branch
git worktree add ../worktrees/feature-name feature-branch

# Create new branch
git worktree add -b feature/new ../worktrees/new-feature

# Detached HEAD (specific commit)
git worktree add ../worktrees/temp HEAD~5
List Worktrees
git worktree list
git worktree list --porcelain  # Machine-readable
Remove Worktree
git worktree remove ../worktrees/name        # Safe (clean only)
git worktree remove --force ../worktrees/name  # Force removal
git worktree prune                           # Clean administrative data
Lock/Unlock
git worktree lock ../worktrees/name    # Prevent operations
git worktree unlock ../worktrees/name

Workflow Patterns

Feature Development
git worktree add -b feature/new ../worktrees/feature/new
cd ../worktrees/feature/new
# ... develop ...
cargo test  # Test in isolation
git push
cd /path/to/main && git merge feature/new
git worktree remove ../worktrees/feature/new
Parallel Testing
for branch in feature/a feature/b; do
  git worktree add ../worktrees/$branch $branch
  cd ../worktrees/$branch && cargo test &
done
wait
Code Review
git worktree add ../worktrees/review/pr-123 origin/pr-123
cd ../worktrees/review/pr-123
cargo test
git worktree remove ../worktrees/review/pr-123

Find Orphaned Worktrees

git worktree list | while read path commit branch; do
  if ! git show-ref --verify --quiet "refs/heads/${branch#*/}"; then
    echo "Orphaned: $path"
  fi
done

Best Practices

DO
  • Organize in ../worktrees/ directory
  • Use descriptive branch-based names
  • Clean up after merging
  • Test before merging to main
  • Prune regularly to remove orphaned data
DON'T
  • Create in random locations
  • Leave with uncommitted changes
  • Forget to prune administrative data
  • Create conflicting branches
  • Mix worktree/non-worktree workflows

Comments

Markdown supported