A CLI tool that automatically creates symlinks from a main git worktree to a new worktree based on glob patterns.
Short alias wtl is also available.
- Share
node_modulesacross worktrees (avoid installing dependencies per worktree) - Share environment files like
.env/.env.local - Share build caches and artifacts like
.next/,tmp/,dist/ - Share IDE settings (
.idea/,.vscode/)
brew install km-tr/tap/worktree-linkcurl --proto '=https' --tlsv1.2 -LsSf https://github.com/km-tr/worktree-link/releases/latest/download/worktree-link-installer.sh | shcargo install --path .Note: The
wtlalias is only available when installed via Homebrew or the shell script installer. When building from source, only theworktree-linkbinary is installed.
worktree-link [OPTIONS]
wtl [OPTIONS]
| Option | Description | Default |
|---|---|---|
-s, --source <DIR> |
Source directory (main worktree) | Auto-detected via git worktree list |
-t, --target <DIR> |
Target directory (new worktree) | . (current directory) |
-c, --config <FILE> |
Path to config file | <SOURCE>/.worktreelinks |
-n, --dry-run |
Show what would be done without making changes | false |
-f, --force |
Overwrite existing files/symlinks | false |
-v, --verbose |
Enable verbose logging | false |
--unlink |
Remove symlinks previously created by worktree-link | false |
--no-ignore |
Do not respect .gitignore rules | false |
# Create symlinks (auto-detect source from git, target is current directory)
wtl
# Specify the source directory explicitly
wtl -s /path/to/main
# Specify the target directory explicitly
wtl -t /path/to/feature-branch
# Specify both source and target
wtl -s /path/to/main -t ./feature-branch
# Preview with dry-run before creating links
wtl --dry-run
# Overwrite existing files/symlinks
wtl --force
# Remove previously created symlinks
wtl --unlink
# Disable .gitignore filtering
wtl --no-ignoreCreate a .worktreelinks file in your project root and list the files/directories to link using gitignore-compatible glob patterns.
# Dependencies
node_modules
# Environment variables
.env
.env.*
# Build artifacts and caches
.next/
tmp/
dist/
# IDE settings
.idea/
.vscode/settings.json
# Monorepo packages
packages/*/node_modules- Lines starting with
#are comments - Blank lines are ignored
- Patterns ending with
/match directories only *matches any character except/**matches across directory boundaries- Patterns starting with
!are negation (exclusion) patterns
When a pattern matches a directory (e.g. node_modules), the entire directory is symlinked as a single unit rather than linking individual files inside it.
Symlinks are created using absolute paths, making them resilient to worktree relocation.
- The
.git/directory is always excluded - Existing files, symlinks, and directories are never overwritten unless
--forceis specified (directories are removed recursively) --unlinkonly removes symlinks that point into the source directory
worktree-link uses Unix symlink APIs (#[cfg(unix)]). Non-Unix platforms (e.g. native Windows) are not supported. On Windows, use WSL or a similar Unix-like environment.
Currently only tested on macOS. Linux should work but is not regularly tested.
# Build
cargo build
# Test
cargo test
# Debug run
cargo run -- --dry-run -s /path/to/source -t /path/to/targetMIT