JSPM

git-worktree-manager

0.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q39107F
    • License MIT

    Interactive CLI for managing Git worktrees

    Package Exports

    • git-worktree-manager
    • git-worktree-manager/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (git-worktree-manager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Git Worktree Manager

    An interactive CLI tool for managing Git worktrees with ease. Built with TypeScript, React Ink, and Bun.

    Features

    • 🌳 Interactive CLI - Beautiful terminal interface using React Ink
    • 🚀 Create Worktrees - Easy worktree creation with branch selection
    • 📝 List Worktrees - View all worktrees with status information
    • 🗑️ Delete Worktrees - Safe deletion with confirmation prompts
    • ⚙️ Configuration - Customizable settings and file copying patterns
    • 🔧 Post-Create Commands - Run commands after worktree creation
    • 📁 File Copying - Automatically copy specified files to new worktrees

    Installation

    # Clone the repository
    git clone <repository-url>
    cd git-worktree-manager
    
    # Install dependencies
    bun install
    
    # Build the project
    bun run build
    
    # Make it globally available (optional)
    bun link

    Usage

    Interactive Mode

    # Start the interactive menu
    bun run dev
    # or after building:
    ./dist/index.js

    Direct Commands

    # Create a new worktree
    bun run dev create
    
    # List all worktrees
    bun run dev list
    
    # Delete a worktree
    bun run dev delete
    
    # Open settings
    bun run dev settings

    Command Line Options

    # Show help
    bun run dev --help
    
    # Show version
    bun run dev --version
    
    # Start in specific mode
    bun run dev --mode create

    Configuration

    The tool looks for configuration files in this order:

    1. .gwmrc.json in current directory
    2. .gwm.json in current directory
    3. gwm.config.json in current directory
    4. Global config in ~/.config/git-worktree-manager/

    Default Configuration

    {
      "worktreeCopyPatterns": [".env", ".vscode/**"],
      "worktreeCopyIgnores": [
        "**/node_modules/**",
        "**/dist/**",
        "**/.git/**",
        "**/Thumbs.db",
        "**/.DS_Store"
      ],
      "worktreePathTemplate": "$BASE_PATH.worktree",
      "postCreateCmd": "",
      "terminalCommand": ""
    }

    Configuration Options

    • worktreeCopyPatterns - Glob patterns for files to copy to new worktrees
    • worktreeCopyIgnores - Glob patterns for files to exclude from copying
    • worktreePathTemplate - Template for worktree directory path
    • postCreateCmd - Command to run after creating a worktree
    • terminalCommand - Terminal command to open the new worktree

    Template Variables

    Available in worktreePathTemplate and postCreateCmd:

    • $BASE_PATH - Repository folder name
    • $WORKTREE_PATH - Full path to the worktree
    • $BRANCH_NAME - Name of the new branch
    • $SOURCE_BRANCH - Name of the source branch

    Development

    Prerequisites

    • Bun runtime
    • Git repository for testing

    Development Scripts

    # Run in development mode
    bun run dev
    
    # Build the project
    bun run build
    
    # Run linting
    bun run lint
    
    # Format code
    bun run format
    
    # Run tests
    bun run test

    Project Structure

    src/
    ├── components/           # React Ink UI components
    │   ├── common/          # Reusable UI components
    │   ├── app.tsx          # Main application
    │   ├── create-worktree.tsx
    │   ├── list-worktrees.tsx
    │   ├── delete-worktree.tsx
    │   └── settings-menu.tsx
    ├── services/            # Business logic services
    │   ├── git-service.ts
    │   ├── config-service.ts
    │   ├── file-service.ts
    │   └── worktree-service.ts
    ├── utils/               # Utility functions
    ├── types/               # TypeScript definitions
    ├── constants/           # Application constants
    └── index.tsx           # CLI entry point

    Requirements

    • Git repository (must be run from within a Git repository)
    • Node.js 18+ or Bun runtime
    • Terminal with Unicode support for best experience

    License

    MIT

    Contributing

    1. Fork the repository
    2. Create a feature branch
    3. Make your changes
    4. Run tests and linting
    5. Submit a pull request

    Troubleshooting

    Common Issues

    "Not a git repository"

    • Ensure you're running the command from within a Git repository

    Permission errors

    • Make sure the built binary has execute permissions: chmod +x dist/index.js

    Missing dependencies

    • Run bun install to install all required dependencies

    Build failures

    • Ensure you have the latest version of Bun installed
    • Try cleaning node_modules and reinstalling: rm -rf node_modules && bun install