git-worktree

Generates Git commands for safe branch matching in worktrees.

3|1|Updated Dec 3, 2025
One-click install
npx skills add https://github.com/nsheaps/ai-mktpl --skill git-worktree-nsheaps
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree
Source: https://github.com/nsheaps/ai-mktpl/tree/main/plugins/scm-utils/skills/git-worktree
Command: npx skills add https://github.com/nsheaps/ai-mktpl --skill git-worktree-nsheaps

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents dangerous mismatches between local branch names and remote branch names when using Git worktrees, which can lead to conflicting pushes, lost work, and confusing repository state.

Core Features & Use Cases

  • Branch-name enforcement: Advises that local branch names must exactly match remote branch names to enable Git's built-in worktree protections.
  • PR checkout guidance: Recommends gh pr checkout where available and provides manual fetch plus git worktree add workflows for creating worktrees that track PR branches safely.
  • Cleanup and conventions: Covers directory naming conventions for worktrees and the correct removal process to unblock branches for other checkouts.

Quick Start

Create a new worktree for PR 42 ensuring the local branch name matches the remote branch and show the exact git commands to perform this safely.

Frequently Asked Questions about git-worktree

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

FAQPage Schema
Why does git worktree checkout fail with conflicting pushes and duplicate branches?

Git worktree checkout fails when local branch names mismatch remote branch names, bypassing Git's built-in worktree protections and causing conflicting pushes. Ensuring local names exactly match remote names prevents this dangerous repository state and duplicate checkouts.

How do I safely checkout a pull request into a new git worktree?

To safely checkout a pull request into a git worktree, use gh pr checkout or run git fetch followed by git worktree add, ensuring the local branch name exactly matches the remote PR branch name to enable Git's worktree protections.

What is the correct way to clean up a git worktree after reviewing a PR?

Correct git worktree cleanup involves following the proper removal process to unblock branches for other checkouts and maintaining consistent directory naming conventions, preventing stale worktree references from blocking future branch checkouts.

Can I use git worktree for multi-agent development without causing branch conflicts?

Git worktree supports multi-agent development scenarios safely when local branch names exactly match remote branch names, enabling Git's built-in worktree protections to prevent duplicate checkouts and conflicting pushes across multiple concurrent worktrees.

Does gh pr checkout work with git worktree add for remote branch tracking?

gh pr checkout and git worktree add work together for remote branch tracking when local branch names match remote names exactly. This combination enables Git's worktree protections for safe multi-worktree PR review scenarios.

What happens if my local branch name doesn't match the remote in a git worktree?

Mismatched local and remote branch names in git worktrees cause duplicate checkouts, conflicting pushes, and lost work by bypassing Git's built-in worktree protections. Exact name matching is required to maintain a safe, consistent repository state.