| Crates.io | worktree |
| lib.rs | worktree |
| version | 0.4.0 |
| created_at | 2025-08-29 17:36:42.441336+00 |
| updated_at | 2025-09-22 03:49:16.229429+00 |
| description | A powerful CLI tool for managing git worktrees with enhanced features including centralized storage, automatic config file synchronization, and intelligent branch management |
| homepage | https://github.com/cafreeman/worktree |
| repository | https://github.com/cafreeman/worktree |
| max_upload_size | |
| id | 1816202 |
| size | 212,131 |
A powerful CLI tool for managing git worktrees with enhanced features that simplify multitasking across multiple branches.
worktree?worktree solves the common problem of needing to work on multiple git branches simultaneously. Instead of constantly switching branches and losing your work context, worktree creates separate working directories for each branch while sharing the same git history.
Key Benefits:
~/.worktrees/<repo-name>/<branch-name>/.env, .vscode, etc.) to new worktreescargo install worktree
Important: The worktree command is a shell function that wraps worktree-bin to enable directory changing and provides enhanced tab completions automatically. Without this integration, worktree jump/worktree switch and worktree back won't be able to change your current directory.
Add the following to your shell configuration:
# Add to ~/.bashrc
eval "$(worktree-bin init bash)"
# Add to ~/.zshrc
eval "$(worktree-bin init zsh)"
# Add to ~/.config/fish/config.fish
worktree-bin init fish | source
| Command | Description |
|---|---|
create <branch> |
Create a new worktree for the specified branch |
list |
List all worktrees across all repositories |
jump [branch] |
Switch to a worktree (interactive if no branch specified) |
switch [branch] |
Alias for jump - switch to a worktree |
remove [branch] |
Remove a worktree (interactive if no branch specified) |
status |
Show detailed status of current worktree and branches |
sync-config <from> <to> |
Copy config files between worktrees |
back |
Return to the original repository |
cleanup |
Clean up orphaned worktree references |
jump/switch without arguments opens an interactive worktree selectorremove without arguments opens an interactive removal menujump, switch, and remove commandsThe shell integration provides intelligent autocomplete:
jump and removeworktree is designed for developers who need to multitask across different features, especially when working with LLM coding assistants:
# Create worktrees for different features
worktree create feature/user-auth
worktree create feature/payment-system
worktree create bugfix/security-patch
# Switch to auth feature (using jump or switch alias)
worktree jump feature/user-auth
# or
worktree switch feature/user-auth
# Work with your LLM assistant on authentication...
# Quickly switch to payment feature
worktree switch feature/payment-system
# Work on payment system while auth context is preserved...
# See what you're working on
worktree list
worktree status
# Sync config changes between worktrees
worktree sync-config feature/user-auth feature/payment-system
# Clean up completed features
# By default, branch will be deleted only if it was created by this CLI
worktree remove feature/user-auth
# To keep the branch
worktree remove feature/user-auth --keep-branch
# To force-delete an unmanaged branch (e.g., created outside this CLI)
worktree remove feature/user-auth --force-delete-branch
# Return to main repo
worktree back
.env, .vscode, IDE settings) are automatically copied~/.worktrees/ for easy managementworktree organizes all worktrees in a centralized location:
~/.worktrees/
├── my-project/
│ ├── main/
│ ├── feature-auth/
│ └── bugfix-security-patch/
└── another-project/
├── main/
└── feature-api/
Branch names with special characters are automatically sanitized for filesystem safety:
feature/user-auth → feature-user-authhotfix/security:patch → hotfix-security-patchCreate a .worktree-config.toml in your repository root to customize which files are copied to new worktrees. The configuration system is flexible and supports partial configurations that merge with sensible defaults.
[copy-patterns]
include = [
".env*",
".vscode/",
"*.local.json",
"config/local/*",
".idea/",
"docker-compose.override.yml"
]
exclude = [
"node_modules/",
"target/",
".git/",
"*.log",
"*.tmp",
"dist/",
"build/"
]
You can specify only the patterns you want to customize. Your configuration merges with defaults using precedence rules:
# Add custom includes (merges with defaults)
[copy-patterns]
include = ["mise.toml", "docker-compose.yml"]
# Result: Default includes + custom includes + default excludes
# Add custom excludes (merges with defaults)
[copy-patterns]
exclude = ["*.secret", "private/"]
# Result: Default includes + default excludes + custom excludes
Your configuration wins when there are conflicts:
# Include something normally excluded by default
[copy-patterns]
include = ["node_modules/.cache"]
# Result: Default includes + node_modules/.cache + default excludes
# (node_modules/.cache gets included despite node_modules/ being excluded)
# Exclude something normally included by default
[copy-patterns]
exclude = [".vscode/"]
# Result: Default includes + default excludes + .vscode/
# (.vscode/ gets excluded despite being included by default)
This approach is simple and intuitive - your choices always override the defaults when there's a conflict.
If no config file exists, these patterns are used:
.env*, .vscode/, *.local.json, config/local/*node_modules/, target/, .git/, *.log, *.tmpSync configuration changes between worktrees without manual copying:
# Copy config files from one worktree to another
worktree sync-config feature/auth feature/payment
Remove orphaned references and clean up unused worktrees:
# Clean up all orphaned worktree references
worktree cleanup
Override the default storage location with an environment variable:
export WORKTREE_STORAGE_ROOT=/path/to/custom/location