nv-worktree-commands

Documents git worktree commands for creating, inspecting, and cleaning up parallel working directories.

39.7k|4.4k|Updated Aug 26, 2021
One-click install
npx skills add https://github.com/novuhq/novu --skill nv-worktree-commands
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nv-worktree-commands
Source: https://github.com/novuhq/novu/tree/main/.cursor/skills/nv-worktree-commands
Command: npx skills add https://github.com/novuhq/novu --skill nv-worktree-commands

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Setting up git worktrees for parallel branch development involves many error-prone details: path naming conventions, copying gitignored .env files, installing dependencies with the right package manager, and safe cleanup. This Skill provides a single command reference so agents and developers implement worktree workflows correctly without rediscovering these steps.

Core Features & Use Cases

  • Path Naming Convention: Deterministic rules for deriving worktree directory names from branch names (lowercase, slashes converted to dashes), with collision checks against existing paths.
  • Environment File Copying: rsync and git ls-files based recipes to copy only local secret .env files (never .env.example or .env.template) from the main checkout into the new worktree.
  • Dependency Install and Cleanup: Lockfile-based package manager detection (pnpm, yarn, npm, bun) plus safe removal with git worktree remove and prune.
  • Use Case: When working on a feature branch like nv-1234/foo-bar, use this reference to create a sibling worktree at ../nv-1234-foo-bar, copy the Novu app's .env files from the parent checkout, run pnpm install, and later remove the worktree cleanly.

Quick Start

Ask the agent to create a git worktree for a new branch following the nv-worktree-commands reference, including copying local env files and installing dependencies.

Frequently Asked Questions about nv-worktree-commands

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

FAQPage Schema
How do I create a git worktree for a new branch?

Run git worktree add -b <branch> <worktree-path> from the repository root to create a new branch in a separate working directory. To base it on a specific ref, append the base such as main, origin/main, a tag, or a commit SHA.

How do I copy .env files into a new git worktree?

Git worktree add does not copy gitignored files, so use rsync with explicit includes for .env and .env.* while excluding .env.example and .env.template. An alternative uses git ls-files --others --ignored to copy only ignored env files.

Which package manager command should I run in a worktree?

Detect the package manager from the lockfile: pnpm-lock.yaml means pnpm install, yarn.lock means yarn install, package-lock.json means npm install, and bun.lockb means bun install. Run the command from the worktree root.

Why does my worktree fail to connect to local Mongo or Redis?

This happens when a new STORE_ENCRYPTION_KEY is generated instead of copying the parent's .env files. Copy env files from the parent checkout rather than running setup scripts that regenerate secrets, so the worktree matches shared local services.

How do I safely remove a git worktree?

Run git worktree remove <worktree-path> followed by git worktree prune. Commit or discard uncommitted work first, and only use --force when explicitly requested.