using-git-worktrees

Create isolated Git worktrees for feature branches while preserving the main workspace.

178|24|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/ZhanlinCui/Ultimate-Agent-Skills-Collection --skill using-git-worktrees-zhanlincui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/ZhanlinCui/Ultimate-Agent-Skills-Collection/tree/main/using-git-worktrees
Command: npx skills add https://github.com/ZhanlinCui/Ultimate-Agent-Skills-Collection --skill using-git-worktrees-zhanlincui

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables developers to create isolated Git worktrees for feature work, preserving the main workspace and avoiding accidental changes to active branches.

Core Features & Use Cases

  • Automatic directory priority: prefers .worktrees, then worktrees, then CLAUDE.md preferences.
  • Safety-first setup: verifies gitignore and prompts for safe global or local worktree locations.
  • Use-case ready: enables rapid feature isolation, testing, and parallel development without context switching.

Quick Start

Create an isolated worktree for a new feature branch and prepare the environment:

  • Check for existing worktree directories: ls -d .worktrees 2>/dev/null; ls -d worktrees 2>/dev/null
  • Determine location and create worktree: git worktree add ".worktrees/feature-branch" -b feature-branch
  • Verify ignore rules: git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
  • Enter worktree: cd ".worktrees/feature-branch"
  • Run project setup as applicable (e.g., npm install, cargo build)

Frequently Asked Questions about using-git-worktrees

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an isolated Git worktree for feature development?

To create an isolated Git worktree, you add a new branch to a separate directory using `git worktree add`, which preserves your main workspace and prevents accidental changes to active branches during feature development.

What is the best way to manage multiple Git branches without context switching?

Using Git worktrees is the best way to manage multiple branches without context switching, as it allows you to maintain separate working directories for parallel development and testing on the same project simultaneously.

How does Git worktree isolation handle directory selection and gitignore safety?

Git worktree isolation handles safety by checking gitignore rules to ensure worktree directories are ignored, and it selects locations using a priority system that prefers `.worktrees`, then `worktrees`, then configuration preferences.

Can I run project setup and toolchain installation inside a new Git worktree?

Yes, after entering a new Git worktree, you can run project setup commands like `npm install` or `cargo build` to prepare the environment, ensuring a clean baseline is validated before feature work begins.

Do I need a global configuration to store worktrees outside my project directory?

You do not need a global configuration, but if you prefer storing worktrees outside the project, the setup supports a global location at `~/.config/superpowers/worktrees` and will prompt you to ensure safe directory selection.

Why should I use Git worktrees instead of cloning repositories for parallel feature work?

Git worktrees share the same repository history, avoiding the disk space and synchronization overhead of cloning, while providing a priority-based directory system and automated setup to rapidly isolate features safely.