WorktreeInitializer 1.2.0
dotnet tool install --global WorktreeInitializer --version 1.2.0
dotnet new tool-manifest
dotnet tool install --local WorktreeInitializer --version 1.2.0
#tool dotnet:?package=WorktreeInitializer&version=1.2.0
nuke :add-package WorktreeInitializer --version 1.2.0
WorktreeInitializer
A tool for copying gitignored files from a source repository to a new worktree. Works as both a CLI tool and an MCP (Model Context Protocol) server for AI agents.
When you create a git worktree, gitignored files like .env files, launchSettings.json with secrets, node_modules/, build outputs, and other local configuration are not included. This tool copies all of them over in one command.
Installation
dotnet tool install --global WorktreeInitializer
After installation, the wi command will be available globally.
To update to the latest version:
dotnet tool update --global WorktreeInitializer
To uninstall:
dotnet tool uninstall --global WorktreeInitializer
To register it as an MCP tool in Claude Code:
claude mcp add worktree-init -- wi --mcp
For Cursor or other MCP clients, add this to your MCP configuration:
{
"mcpServers": {
"worktree-init": {
"command": "wi",
"args": ["--mcp"]
}
}
}
Usage
wi init <source-path> <destination-path> [--ignore <path>]...
wi help
Examples
# Copy gitignored files from your main repo to a new worktree
wi init C:\code\myproject C:\code\myproject-worktree
# Exclude specific directories from copying
wi init ./myproject ./myproject-worktree --ignore node_modules --ignore .venv
# Works with paths containing spaces (just quote them)
wi init "/home/user/my project" "/home/user/my project-wt"
# Unix paths work the same way
wi init ~/code/myproject ~/code/myproject-worktree
WorktreeConfig.json
You can place a WorktreeConfig.json file in the source repo root to define default ignores:
{
"ignores": ["node_modules", ".venv", "dist"]
}
- The file is optional — if missing, no default ignores are applied
- If present but malformed, an error is reported
- CLI
--ignoreflags are merged with config file ignores (union of both)
Behavior
Discovers ignored files using git
Runs git ls-files --others --ignored --exclude-standard in the source directory. This handles all .gitignore complexity: nested .gitignore files, global gitignore, .git/info/exclude, negation patterns, and every other gitignore feature.
Preserves directory structure
Files are copied to the same relative path in the destination. If src/bin/Debug/app.dll is ignored in the source, it will be copied to src/bin/Debug/app.dll in the destination.
Creates directories as needed
If the destination directory structure doesn't exist yet, it is created automatically during the copy.
Overwrites existing files
If a file already exists in the destination, it is overwritten. This makes it safe to re-run wi init if the source files have changed.
Partial failures are reported
If some files fail to copy (e.g. locked by another process), the rest are still copied. The output lists which files failed and why.
Requires git in PATH
Since the tool uses git ls-files to discover ignored files, git must be installed and available in PATH. If you're using git worktrees, you already have git installed.
As MCP Server
wi --mcp
When running as an MCP server, the following tools are available:
wi_init(sourcePath, destinationPath, ignorePaths?)- Copy all gitignored files from source to destinationwi_help()- Get help
Development
git clone <repository-url>
cd worktree-initializer
dotnet build WorktreeInitializer.slnx
dotnet test WorktreeInitializer.slnx
To run as MCP server during development:
dotnet run --project WorktreeInitializer.Cli/WorktreeInitializer.Cli.csproj -- --mcp
To package:
dotnet pack WorktreeInitializer.Cli/WorktreeInitializer.Cli.csproj --configuration Release
License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.