ev worktree
Usage
Description
ev worktree wraps git worktree with automatic secret sync. When you create a worktree, ev pull runs inside it automatically so secrets are ready without any extra steps.
Worktrees are stored under .worktrees/ by default (configurable in ev.yaml). This keeps them co-located with the repo and out of your main working tree.
Subcommands
add
Creates a git worktree at .worktrees/<name>, then pulls secrets into it.
| Argument/Option | Description |
|---|---|
<name> | Worktree directory name. Also used as the new branch name if [branch] is omitted. |
[branch] | Existing branch to check out. If omitted, a new branch named <name> is created. |
--env <env> | Environment to pull. Defaults to default_env from ev.yaml. |
Examples:
After creation, your shell automatically cds into the new worktree (requires shell setup).
remove
Removes the worktree at .worktrees/<name>. Delegates to git worktree remove — no extra cleanup needed since .env files are gitignored.
list
Lists all worktrees. Pass-through to git worktree list.
Shell Setup
To get automatic cd into the new worktree after ev worktree add, run once:
This writes a shell function to your ~/.zshrc or ~/.bashrc (auto-detected from $SHELL). The function intercepts ev worktree add, runs it normally, then cds into the result. It's idempotent — safe to re-run after updates.
To specify shell or file explicitly:
After installing, reload your shell:
Configuration
Control where worktrees are created via ev.yaml:
The directory is relative to the repo root (where ev.yaml lives). On first ev worktree add, the directory is added to .gitignore automatically.
Monorepo Behavior
In a monorepo with apps: configured, ev worktree add pulls secrets for all apps into the new worktree:
This mirrors what ev pull does when run from the repo root.
AI Agents & Worktrees
AI coding tools — Claude, Cursor, GitHub Copilot Workspace — increasingly use git worktrees to work on multiple branches in parallel without losing context. ev worktree add makes this seamless: the agent gets a fully-configured environment with secrets in one command, no manual secret setup required.
Each worktree is completely isolated — changes to .env in one worktree don't affect any other.
If Pull Fails
If the secret pull fails (network issue, not logged in), the worktree is left in place and a retry command is printed:
The worktree itself is still usable — secrets just need to be pulled manually.