using-git-worktrees

Create Git worktrees for isolated feature development and cleanup optionally deleting branches.

3|Updated May 12, 2019
One-click install
npx skills add https://github.com/good-idea/dotfiles --skill using-git-worktrees-good-idea
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/good-idea/dotfiles/tree/main/opencode/skill/using-git-worktrees
Command: npx skills add https://github.com/good-idea/dotfiles --skill using-git-worktrees-good-idea

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This skill enables developers to safely start feature work by isolating it in a dedicated Git worktree, avoiding pollution of the main working tree.

Core Features & Use Cases

  • Create isolated worktrees for a specific branch at .worktrees/<branch>.
  • Automatically add .worktrees/ to .gitignore if missing and commit.
  • Auto-detect worktree location, preferring .worktrees and fall back to worktrees as needed.
  • Clean up by removing a worktree and optionally deleting its associated branch.
  • Supports workflow: announce, create, navigate, set up, test, and cleanup.

Quick Start

Announce you're using the skill, run ./scripts/create-worktree.sh <branch-name>, then cd into the resulting directory and proceed with project setup (install dependencies) and tests. When finished, run ./scripts/cleanup-worktree.sh <worktree-path> [--delete-branch] if desired.

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 isolated git worktrees for parallel feature development?

To create isolated git worktrees, run the create-worktree script with a branch name, which automatically generates a dedicated directory at .worktrees/<branch> to keep your main working tree clean.

What is the best way to manage multiple feature branches without polluting the main workspace?

Using git worktrees is the best way to manage multiple branches without pollution, as it isolates each feature in a separate directory while automatically verifying .gitignore safety and preventing main workspace conflicts.

How do I clean up a git worktree and delete its associated branch?

To clean up a git worktree, run the cleanup-worktree script with the worktree path and optionally pass the --delete-branch flag to remove both the isolated directory and its associated feature branch.

Does the worktree automation automatically update .gitignore?

Yes, the worktree automation automatically adds the .worktrees/ directory to your .gitignore file if it is missing, and commits this change to ensure your isolated workspaces remain untracked.

Can I auto-detect the worktree location if I use a different directory naming convention?

Yes, you can auto-detect the worktree location, as the scripts prefer the .worktrees directory path but will automatically fall back to the worktrees directory name if the primary location is unavailable.

What is the standard workflow for developing a feature in an isolated git worktree?

The standard git worktree workflow follows the sequence of announce, create, navigate, set up dependencies, test, and cleanup, ensuring safe branch isolation throughout the entire feature development lifecycle.