using-git-worktrees

alexei-led 的头像作者 alexei-led

在需要与当前工作区隔离或执行实施计划前开始功能工作时使用。创建具有智能目录选择和安全验证的隔离git工作树。

📖 中文导读:在需要与当前工作区隔离或执行实施计划前开始功能工作时使用。创建具有智能目录选择和安全验证的隔离git工作树。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: using-git-worktrees description: Creates isolated git worktrees for parallel development. Use when starting feature work needing isolation or working on multiple branches simultaneously. Not for simple branch switching or basic git operations. allowed-tools: - Read - Bash - Grep - Glob

Git Worktrees

Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously.

Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."

Quick Start

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

# Create worktree from existing branch
git worktree add .worktrees/bugfix bugfix/issue-123

# List worktrees
git worktree list

# Remove worktree
git worktree remove .worktrees/feature-auth

Directory Selection

  1. Check existing: .worktrees/ or worktrees/
  2. Check CLAUDE.md for preference
  3. Ask user if neither exists

Safety Requirements

Before creating project-local worktree:

# Verify directory is in .gitignore
grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore

If NOT in .gitignore: Add it immediately and commit.

References