using-git-worktrees

Create isolated Git worktrees with directory safety checks and baseline validation.

68|6|Updated Apr 16, 2020
One-click install
npx skills add https://github.com/zenobi-us/dotfiles --skill using-git-worktrees-zenobi-us
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/zenobi-us/dotfiles/tree/main/devtools/files/opencode/skills/using-git-worktrees
Command: npx skills add https://github.com/zenobi-us/dotfiles --skill using-git-worktrees-zenobi-us

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing multiple feature branches or experiments often leads to context switching, messy workspaces, and accidental commits, slowing down development and increasing the risk of errors.

Core Features & Use Cases

  • Isolated Workspaces: Create clean, independent Git worktrees for parallel development without branch switching.
  • Smart Directory Selection: Automatically or interactively choose optimal locations for worktrees, with .gitignore verification.
  • Automated Setup: Auto-detect and run project-specific setup commands (e.g., npm install, cargo build) for a ready-to-use environment.
  • Use Case: You're working on a critical bug fix but need to start a new feature. Use this Skill to create a clean, isolated workspace for the new feature without disturbing your current branch, ensuring no conflicts or accidental commits.

Quick Start

Use the using-git-worktrees skill to create a new worktree for a feature branch named 'feature/new-dashboard'.

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?

Git worktrees let you create independent workspace copies linked to different branches, eliminating context switching. Set up a worktree by specifying a branch name and directory—the Skill auto-detects your project type, runs setup commands like `npm install` or `cargo build`, and verifies the baseline with tests, giving you a ready-to-use isolated environment.

What's the best way to manage multiple feature branches without workspace conflicts?

Worktrees solve workspace conflicts by isolating each branch in its own directory, preventing accidental commits to the wrong branch. Instead of switching branches repeatedly, maintain parallel worktrees—one per feature—so you work cleanly on multiple features simultaneously without contaminating your current workspace.

Does Git worktree setup handle my project's dependencies automatically?

Yes, the Skill auto-detects Node, Rust, Python, and Go projects and runs project-specific setup commands automatically. It installs dependencies, builds artifacts as needed, and runs baseline tests to ensure your worktree is functional before you start coding.

Can I use worktrees if my repository has complex directory structures or .gitignore rules?

The Skill includes safety verification that checks `.gitignore` rules before creating worktrees, ensuring optimal directory placement. It respects your repository's structure and version control configuration, so worktrees integrate cleanly with existing ignore patterns and nested layouts.

Why should I use worktrees instead of just switching branches?

Branch switching loses your working state, rebuild times are wasted, and you risk accidentally committing to the wrong branch. Worktrees keep your contexts completely separate—each branch has its own files, build artifacts, and state—so you switch projects instantly without interruption or cleanup.

How does Git worktree isolation prevent accidental commits to the wrong branch?

Each worktree is a separate directory with its own working tree tied to a specific branch. You work in the correct directory for each feature, so Git commits automatically go to the intended branch—there's no risk of pushing changes to the wrong branch because you're working in isolated, branch-specific directories.