---
title: "Copy .env and other ignored files into worktrees"
description: "Which ignored files microManager copies into new workspaces, how .worktreeinclude, file_include_globs and .env* are chosen, and what is never overwritten."
url: "https://micromanager.win/docs/files-to-copy"
updated: "2026-11-08"
---

# Files to copy

A new git worktree has none of your ignored files, so microManager copies them in from the repository’s main checkout. It uses .worktreeinclude when the repository has one, otherwise file_include_globs from the repository settings, otherwise every .env\* file.

Updated 8 November 2026

## Why do I need to copy files into a worktree?

`git worktree add` checks out only what is committed. Files your `.gitignore` excludes, such as `.env`, local certificates or a `config/secrets.json`, are not there, so a dev server or test run in the new worktree fails until you copy them. microManager does this for you every time it creates or restores a workspace.

## How does microManager decide which files to copy?

It uses the first of these that the repository has:

| Order | Source                                          | Format                                          |
| ----- | ----------------------------------------------- | ----------------------------------------------- |
| 1     | `.worktreeinclude` in the repository root       | One pattern per line, written like `.gitignore` |
| 2     | `file_include_globs` in the repository settings | A list of glob patterns in TOML                 |
| 3     | Built-in default                                | `.env*`                                         |

Only one source is used: a `.worktreeinclude` file replaces `file_include_globs` rather than adding to it.

## What does a `.worktreeinclude` file look like?

```text
# .worktreeinclude
.env
.env.local
config/secrets.json
certs/*.pem
```

Lines follow `.gitignore` rules: `#` starts a comment, `*` matches within a folder and `**` across folders. The same file name is read by other tools, including Claude Code’s desktop app and Codex in the ChatGPT desktop app, so one file can serve all of them.

## How do I set `file_include_globs`?

```toml
# .conductor/settings.toml or .micromanager/settings.toml
file_include_globs = [".env", ".env.*", "apps/*/.env.local"]
```

Conductor’s key and format are read as they are, including its other form, one string with a pattern per line. A personal list can go in `settings.local.toml`, which takes precedence over the shared file.

## Which files are never copied or overwritten?

- **Only ignored or untracked files are copied.** A file that git tracks already comes with the checkout.
- **Nothing is overwritten.** If a file already exists in the new worktree, microManager leaves it alone.
- **Ignored folders are searched only when a pattern points into them.** `.env*` does not pull `.env` files out of `node_modules`, while `config/**` does reach into an ignored `config/` folder.
- **Nothing is copied through a linked folder.** If a folder in the new worktree is a symlink, files under it are skipped, so a copy never lands outside the worktree.
- Files come from the repository’s **main checkout** (the folder you added, `$MICROMANAGER_ROOT_PATH`), never from another workspace.

## Can a setup script do the rest?

Yes. For anything copying cannot do, such as generating a file or linking a shared folder, use the [setup script](https://micromanager.win/docs/scripts), which runs after the files are copied and can read `$MICROMANAGER_ROOT_PATH`.

## Where to go next

- [Repository settings keys](https://micromanager.win/docs/repository-settings)
- [Workspaces](https://micromanager.win/docs/workspaces)
