using-git-worktrees

Creates isolated git worktree workspaces with detection, setup, and baseline test verification.

Updated Jan 2, 2025
One-click install
npx skills add https://github.com/mcinnisd/gymbro --skill using-git-worktrees-mcinnisd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/mcinnisd/gymbro/tree/main/.agents/skills/using-git-worktrees
Command: npx skills add https://github.com/mcinnisd/gymbro --skill using-git-worktrees-mcinnisd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It prevents experimental or feature work from polluting your main branch by setting up an isolated git worktree, while avoiding duplicate worktrees, submodule confusion, and accidentally committing worktree contents. ## Core Features & Use Cases - Isolation Detection: Checks whether you are already inside a linked worktree or a submodule before creating anything, using git rev-parse comparisons. - Native Tool Preference: Uses platform-native worktree tools (e.g., EnterWorktree, /worktree commands) when available, falling back to manual git worktree add only when necessary. - Safe Directory Handling: Selects .worktrees/ or worktrees/ directories, verifies they are git-ignored, and commits a .gitignore fix if not. - Project Setup & Baseline Verification: Auto-detects Node.js, Rust, Python, or Go projects, installs dependencies, and runs tests to confirm a clean baseline. - Use Case: Before implementing a new feature, ask the assistant to set up an isolated workspace; it detects your repo state, creates a worktree on a new branch, installs dependencies, and confirms tests pass. ## Quick Start Ask the assistant to set up an isolated git worktree for your current feature branch and verify the project tests pass before starting work.

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 a new feature branch?

Run git worktree add with a target path and the -b flag to create a new branch, for example git worktree add .worktrees/my-feature -b my-feature. The skill automates this after verifying the directory is git-ignored.

How do I check if I am already inside a git worktree?

Compare git rev-parse --git-dir with git rev-parse --git-common-dir. If they differ and you are not in a submodule, you are already in a linked worktree and should not create another one.

What is the difference between a git worktree and a submodule?

Both show different git-dir and git-common-dir paths, but a submodule has a superproject. Run git rev-parse --show-superproject-working-tree; if it returns a path, you are in a submodule and should treat it as a normal repo.

Why should the worktree directory be added to .gitignore?

An unignored worktree directory risks committing the entire nested worktree contents into the repository. Verify with git check-ignore and commit a .gitignore entry before creating the worktree.

What happens if git worktree add fails with a permission error?

A permission error usually means sandbox restrictions blocked worktree creation. The fallback is to inform the user and run project setup and baseline tests directly in the current directory instead.