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 linkUsage
Interactive Mode
# Start the interactive menu
bun run dev
# or after building:
./dist/index.jsDirect 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 settingsCommand Line Options
# Show help
bun run dev --help
# Show version
bun run dev --version
# Start in specific mode
bun run dev --mode createConfiguration
The tool looks for configuration files in this order:
.gwmrc.jsonin current directory.gwm.jsonin current directorygwm.config.jsonin current directory- 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 worktreesworktreeCopyIgnores- Glob patterns for files to exclude from copyingworktreePathTemplate- Template for worktree directory pathpostCreateCmd- Command to run after creating a worktreeterminalCommand- 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 testProject 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 pointRequirements
- 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
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- 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 installto 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