git-worktree

Manages Git worktrees for feature branches, hotfixes, and PR reviews.

1|Updated May 7, 2022
One-click install
npx skills add https://github.com/brandonburrus/dotfiles --skill git-worktree-brandonburrus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree
Source: https://github.com/brandonburrus/dotfiles/tree/main/.config/opencode/skills/git-worktree
Command: npx skills add https://github.com/brandonburrus/dotfiles --skill git-worktree-brandonburrus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you manage multiple Git branches and features in isolated working directories without interfering with your main codebase, preventing context switching issues and WIP disruptions.

Core Features & Use Cases

  • Isolated Workspaces: Create separate directories for feature branches, hotfixes, or PR reviews.
  • Lifecycle Management: Guides the creation, cleanup, and management of Git worktrees.
  • Use Case: You're working on a new feature but need to quickly address a critical bug. This Skill lets you create a separate worktree for the hotfix without committing your unfinished feature work.

Quick Start

Use the git-worktree skill to create a new worktree for the 'feature/new-login' branch under '/project/.worktrees/feature-new-login'.

Frequently Asked Questions about git-worktree

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

FAQPage Schema
How do I work on a hotfix without committing my unfinished feature branch?

You can use a git worktree to create an isolated working directory for the hotfix branch. This allows you to switch contexts and address the bug without stashing or committing unfinished work in your main codebase.

What is the best way to manage multiple Git branches without context switching?

Managing Git worktrees allows you to isolate development tasks for feature branches and pull request reviews in separate directories. This prevents work-in-progress disruptions and context switching issues by keeping each branch in its own working tree.

How do I create a git worktree for a new feature branch?

You can create a git worktree by specifying the target feature branch and a sibling .worktrees/ directory path. This isolates the new workspace under that directory, ensuring all subsequent file operations are scoped correctly.

Does managing git worktrees automatically clean up isolated directories?

Yes, this approach guides the lifecycle management of worktrees, including their creation, navigation, and cleanup. Removing the worktree directory after finishing a feature or hotfix prevents leftover files from interfering with the main working tree.

Can I run bash commands scoped to a specific git worktree path?

Yes, when using isolated worktrees, all file operations and bash commands are scoped to the correct worktree path. This ensures that command execution remains isolated and prevents accidental interference with the main working tree.