npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@t.goto/git-worktree-manager

v1.0.0

Published

Universal Git worktree management tool with project-specific install commands

Readme

Git Worktree Manager (GWM)

🌿 Universal Git worktree management tool with project-specific install commands

Overview

GWM automates the creation and management of Git worktrees with intelligent project detection and customizable install commands. It supports multiple project types and provides a consistent workflow across different development environments.

Features

  • 🔍 Auto-detection: Automatically detects project type (Laravel, React, Django, etc.)
  • 📦 Custom Install Commands: Configurable dependency installation per project
  • 🐳 Docker Integration: Built-in Docker Compose support
  • 🪝 Custom Hooks: Pre/post install hooks for project-specific setup
  • ⚙️ Environment-aware: Different commands for local, docker, production environments
  • 📋 Template System: Pre-configured templates for common project types

Installation

NPM (Recommended)

# グローバルインストール
npm install -g gwm-worktree-manager

# インストール確認
gwm --version

Yarn

# グローバルインストール
yarn global add gwm-worktree-manager

# インストール確認
gwm --version

Local Development

git clone <repository>
cd gwm
npm install
npm link

# または
npm install -g .

Requirements

  • Node.js >= 14.0.0
  • Git >= 2.5.0
  • npm or yarn

Quick Start

1. Initialize in your project

cd your-project
gwm init

This creates a .worktree.yml configuration file with auto-detected settings.

2. Create a worktree

gwm create feature-branch

3. List worktrees

gwm list

4. Remove a worktree

gwm remove feature-branch

Configuration

The .worktree.yml file controls how GWM manages your worktrees:

project:
  name: "my-project"
  type: "php-laravel"

install:
  dependencies: "composer install --no-interaction"
  
environments:
  docker:
    install: "docker compose exec php composer install"
    
scripts:
  test: "php artisan test"
  build: "npm run build"
  quality: "vendor/bin/phpcs && vendor/bin/phpstan"

docker:
  enabled: true
  service: "php"

worktree:
  directory: "../worktrees"
  auto_install: true
  auto_setup: true

Supported Project Types

PHP Laravel

  • Detection: composer.json + artisan + Laravel framework
  • Install: composer install --no-interaction --optimize-autoloader
  • Features: Auto .env creation, Laravel-specific Makefile

Node.js React

  • Detection: package.json + React dependencies
  • Install: npm ci
  • Features: Package.json scripts integration

Python Django

  • Detection: manage.py or requirements.txt with Django
  • Install: pip install -r requirements.txt
  • Features: Virtual environment support

Generic

  • Fallback: For any project type not specifically supported
  • Customizable: Fully configurable via .worktree.yml

Custom Hooks

Create custom setup logic in .worktree/hooks/install.sh:

#!/bin/bash
WORKTREE_PATH="$1"
PROJECT_TYPE="$2"
BRANCH_NAME="$3"

echo "Setting up $BRANCH_NAME..."

# Custom setup logic here
case "$PROJECT_TYPE" in
    "php-laravel")
        cd "$WORKTREE_PATH"
        php artisan key:generate
        php artisan storage:link
        ;;
esac

Commands

gwm init

Initialize worktree configuration for current project

  • Auto-detects project type
  • Generates .worktree.yml configuration
  • Creates hooks directory with samples

gwm create <branch-name>

Create a new worktree for the specified branch

  • Creates Git worktree
  • Runs install commands
  • Sets up project-specific files
  • Creates worktree-specific Makefile (if applicable)

Options:

  • --force: Force creation even if branch exists
  • --no-install: Skip dependency installation

gwm remove <branch-name>

Remove an existing worktree

  • Removes Git worktree
  • Cleans up all worktree-specific files

Options:

  • --force: Skip confirmation prompt

gwm list

List all existing worktrees

  • Shows worktree paths and branch names
  • Indicates main worktree

gwm status

Show worktree manager status and configuration

  • Project information
  • Configuration summary
  • Worktree count

Docker Integration

For Docker-based projects, GWM automatically detects and configures Docker commands:

docker:
  enabled: true
  service: "php"
  compose_file: "docker-compose.yml"

environments:
  docker:
    install: "docker compose exec php composer install"

Commands will automatically use Docker when configured.

Advanced Usage

Environment-specific Commands

environments:
  local:
    install: "composer install"
  docker:
    install: "docker compose exec php composer install"
  production:
    install: "composer install --no-dev --optimize-autoloader"

Set environment: NODE_ENV=docker gwm create feature-branch

Custom Scripts

scripts:
  test: "php artisan test"
  quality: "vendor/bin/phpcs && vendor/bin/phpstan"
  deploy: "rsync -av . production:/"

These are included in generated Makefiles and documentation.

Worktree Directory Customization

worktree:
  directory: "../my-worktrees"  # Custom directory
  auto_install: false           # Manual install
  auto_setup: false            # Manual setup

Examples

Laravel Project

# Initialize
gwm init  # Detects: php-laravel

# Create feature worktree
gwm create feature-payment
# → Creates worktree with:
#   - composer install
#   - .env file from .env.example
#   - Laravel-specific Makefile
#   - Docker integration

# Work in worktree
cd ../worktrees/feature-payment
make test
make migrate

React Project

# Initialize
gwm init  # Detects: node-react

# Create worktree
gwm create feature-ui
# → Creates worktree with:
#   - npm ci
#   - Basic Makefile with npm scripts

# Development
cd ../worktrees/feature-ui
npm start

Troubleshooting

Permission Issues

chmod +x .worktree/hooks/install.sh

Docker Not Found

Ensure Docker is running and docker compose is available.

Custom Project Type

For unsupported project types, use generic and customize .worktree.yml:

project:
  type: "generic"
  
install:
  dependencies: "your-custom-install-command"

Contributing

  1. Fork the repository
  2. Create a feature branch: gwm create feature-new-adapter
  3. Add your adapter in lib/adapters/
  4. Add tests
  5. Submit a pull request

Creating Custom Adapters

// lib/adapters/your-framework.js
module.exports = {
  name: 'your-framework',
  
  async detect(projectRoot) {
    // Detection logic
    return true/false;
  },
  
  install: {
    dependencies: 'your-install-command'
  },
  
  scripts: {
    test: 'your-test-command',
    build: 'your-build-command'
  }
};

License

MIT License - see LICENSE file for details.

Support