git-worktree

Create, list, switch, and clean up Git worktrees with environment file copying.

Updated Jun 28, 2022
One-click install
npx skills add https://github.com/pcasaretto/nix-home --skill git-worktree-pcasaretto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree
Source: https://github.com/pcasaretto/nix-home/tree/main/home-manager/modules/common/pi/compound-engineering/skills/git-worktree
Command: npx skills add https://github.com/pcasaretto/nix-home --skill git-worktree-pcasaretto

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill streamlines the management of Git worktrees, providing an isolated environment for parallel development, code reviews, and feature isolation without disrupting your main codebase.

Core Features & Use Cases

  • Create Worktrees: Easily create new worktrees from a specified branch (defaults to main), automatically copying environment variables.
  • List & Switch: View all active worktrees and seamlessly switch between them.
  • Cleanup: Intelligently remove completed or inactive worktrees.
  • Use Case: When starting a new feature, create a dedicated worktree for it. Later, if you need to quickly review a pull request, create another worktree for that specific PR, all while keeping your main branch clean and stable.

Quick Start

Use the git-worktree skill to create a new worktree for the feature named 'new-login-flow'.

Frequently Asked Questions about git-worktree

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

FAQPage Schema
How do I use Git worktrees for parallel feature development without disrupting my main branch?

Git worktrees allow you to create isolated development directories linked to distinct branches. You can build new features in a dedicated worktree while keeping your main codebase clean, stable, and unaffected by ongoing changes.

What is the best way to manage multiple Git worktrees for separate code reviews?

Managing Git worktrees for code reviews involves creating isolated directories for each pull request. This allows you to review distinct branches simultaneously, switch between them seamlessly, and remove the worktree once the review is complete.

How do I create a Git worktree and automatically copy environment files?

Creating a Git worktree can automatically copy your environment variables into the new isolated directory. This ensures the parallel development environment is properly configured from a specified branch, defaulting to main.

Does Git worktree management automate .gitignore configuration for new branch directories?

Yes, Git worktree management ensures proper .gitignore configuration for newly created worktree directories. This prevents isolated branch environments and copied environment files from being tracked in your version control system.

How do I clean up completed or inactive Git worktrees after feature development?

Cleaning up completed Git worktrees after feature development involves intelligently removing the isolated directories. This safely deletes inactive worktree environments while preserving your main repository and stable branches.

When do I need Git worktrees instead of standard Git branching for isolated development?

You need Git worktrees instead of standard Git branching when you require isolated physical directories for parallel development. This allows simultaneous work on multiple features or code reviews without stashing changes or switching local files.