Copy .env and untracked files into a new worktree

ai agents & parallel sessions

// what it does

A new worktree contains tracked files only. Everything your app needs at runtime but Git ignores — .env, .env.local, certificates, seed databases, tool caches — stays behind in the original checkout. Copy those over right after creating the worktree, before starting an agent or dev server in it.

// shell

$ cp .env .env.local ../myapp-agent-auth/ 2>/dev/null
$ git -C ../myapp-agent-auth status --short

// gotcha

Symlinking .env instead of copying shares live edits across all worktrees — convenient for one developer, risky when an agent rewrites config. And never "fix" the problem by committing the file; it's ignored for a reason.

// resources