git-worktree

Create and manage isolated Git worktrees with submodule initialization.

10|Updated Nov 29, 2025
One-click install
npx skills add https://github.com/benjaminshafii/digital-empire --skill git-worktree-benjaminshafii
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree
Source: https://github.com/benjaminshafii/digital-empire/tree/main/.opencode/skill/git-worktree
Command: npx skills add https://github.com/benjaminshafii/digital-empire --skill git-worktree-benjaminshafii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables safe creation and management of isolated git worktrees to keep feature work separate from the main repository.

Core Features & Use Cases

  • Create a dedicated worktree for a feature branch to isolate changes from the main development line.
  • Initialize and manage submodules inside the new worktree to keep related dependencies consistent.
  • Cleanup and verify worktrees easily, ensuring no destructive actions on existing branches or files.

Quick Start

Use the git-worktree skill to set up and manage isolated worktrees for feature tasks.

  1. Confirm you are in the control-center repository: git rev-parse --show-toplevel
  2. Sync the main branch: git fetch origin --prune git pull --ff-only origin master
  3. Create the worktree for a feature: Pick a feature name, then run: git worktree add -b feat/<name> ../worktrees/feat-<name> master
  4. Initialize submodules inside the new worktree: git -C ../worktrees/feat-<name>/vendor/openwork submodule update --init --recursive
  5. Submodule feature work (example): git -C ../worktrees/feat-<name>/vendor/openwork fetch origin --prune git -C ../worktrees/feat-<name>/vendor/openwork switch -c feat/<name> origin/dev (Optional) install and typecheck within the submodule workspace: pnpm -C ../worktrees/feat-<name>/vendor/openwork install pnpm -C ../worktrees/feat-<name>/vendor/openwork typecheck
  6. Common checks: git worktree list ls ../worktrees git submodule status
  7. Cleanup (Non-destructive): git worktree remove ../worktrees/feat-<name>

Frequently Asked Questions about git-worktree

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

FAQPage Schema
How do I create isolated git worktrees for feature branches without affecting the main repository?

To create an isolated git worktree, run git worktree add -b feat/<name> ../worktrees/feat-<name> master from your control-center repository. This safely separates feature work from the main development line without destructive actions.

How do I initialize and manage git submodules inside a new worktree?

To initialize submodules inside a git worktree, run git -C ../worktrees/feat-<name>/vendor/openwork submodule update --init --recursive. This ensures related dependencies remain consistent across your isolated workspace.

What is the safest way to clean up git worktrees after finishing a feature task?

The safest way to clean up git worktrees is using git worktree remove ../worktrees/feat-<name>. This non-destructive command removes the isolated branch workspace while preserving existing branches and repository files.

Can I manage multiple feature branch worktrees in a single control-center repository?

Yes, you can manage multiple worktrees in a control-center repository by creating separate worktrees under ../worktrees/<name> for each feature branch. Use git worktree list and ls ../worktrees to verify their status.

Do I need standard Git tooling to manage worktrees and submodules for isolated development?

Yes, standard Git tooling is required to manage worktrees and submodules. The skill validates repository state and relies on native git commands to safely create, initialize, and clean up isolated feature branch environments.

Why use git worktrees instead of cloning repositories for separate feature tasks?

Git worktrees provide isolated development branches sharing a single repository history, avoiding full repository clones. This approach keeps feature work separate while maintaining consistent submodule dependencies and easy cleanup.