easy-worktree
v0.1.0
Published
Easy Worktree - A simple wrapper around git worktree
Readme
Easy Worktree
A simple wrapper around git worktree that makes managing Git worktrees effortless.
Features
- 🚀 Simple commands to create worktrees as sibling directories
- 📁 Automatically copies all
.env*anddev.varsfiles (including nested ones) - 🔄 Sanitizes branch names (replaces
/with-for directory names) - 📋 List all worktrees
- 🗑️ Easy worktree removal
Installation
npm install -g easy-worktreePrerequisites
- Node.js >= 14
- Rust and Cargo (install from rustup.rs)
- Git with worktree support
Usage
Create a worktree from existing branch
ew <branch_name>Creates a worktree at ../<branch_name> for the existing branch. Branch names with / are converted to - for the directory name.
Example:
ew feature/new-ui
# Creates worktree at ../feature-new-ui for branch feature/new-uiCreate a worktree with a new branch
ew -b <branch_name>Creates a new branch and worktree at ../<branch_name>.
Example:
ew -b feature/api-update
# Creates new branch feature/api-update and worktree at ../feature-api-updateList all worktrees
ew listShows all worktrees in the repository.
Remove a worktree
ew remove <worktree_path>Removes the specified worktree.
Example:
ew remove ../feature-new-uiHow it works
- Creates a git worktree as a sibling directory (
../) - Sanitizes branch names by replacing
/with-for directory names - Recursively copies all
.env*anddev.varsfiles from the current directory to the new worktree - Preserves directory structure when copying environment files
Environment File Copying
The tool automatically copies:
- All files matching
.env*pattern (e.g.,.env,.env.local,.env.production) - All
dev.varsfiles - Nested environment files in subdirectories
If no environment files are found, the tool continues without error.
Why Easy Worktree?
Git worktrees are powerful but can be tedious to set up, especially when you need to:
- Remember the exact syntax
- Copy configuration files
- Handle branch name sanitization
ew automates all of this, making worktree management as simple as possible.
License
MIT
