Skip to content

Commit cf2a562

Browse files
committed
docs: add copy .env example and link from README
1 parent 36f273d commit cf2a562

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Inspired by [haacked/dotfiles/tree-me](https://github.com/haacked/dotfiles/blob/
1919
- **Interactive selection menus** with fuzzy matching for checkout, remove, pr, and mr commands
2020
- GitHub PR support via `wt pr` command (uses `gh` CLI) — checks out the PR's actual branch name
2121
- GitLab MR support via `wt mr` command (uses `glab` CLI) — checks out the MR's actual branch name
22-
- **Pre/post command hooks** — run custom scripts on create/checkout/remove (e.g. [launch AI assistants](docs/examples.md#ai-assistants-and-editors), [share build caches](docs/examples.md#shared-build-cache-across-worktrees), [assign dev server ports](docs/examples.md#deterministic-dev-server-port-per-worktree), copy `.env`)
22+
- **Pre/post command hooks** — run custom scripts on create/checkout/remove (e.g. [launch AI assistants](docs/examples.md#ai-assistants-and-editors), [share build caches](docs/examples.md#shared-build-cache-across-worktrees), [assign dev server ports](docs/examples.md#deterministic-dev-server-port-per-worktree), [copy `.env`](docs/examples.md#copy-env-to-new-worktrees))
2323
- **Stale worktree detection** — find worktrees with deleted remote branches or inactive commits (`wt cleanup --stale`)
2424
- **Color-coded status output** — green (clean), red (dirty), yellow (ahead/behind), bold cyan (current); respects `NO_COLOR=1` and auto-strips colors when piped
2525
- **Per-repo `.wt.toml` config** — override global settings (strategy, hooks, etc.) on a per-repository basis

docs/examples.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ pre_remove = [
6060
]
6161
```
6262

63+
## Copy `.env` to new worktrees
64+
65+
Automatically copy environment files from the main worktree so new branches are ready to run immediately:
66+
67+
```toml
68+
[hooks]
69+
post_create = [
70+
"test -f $WT_MAIN/.env && cp $WT_MAIN/.env $WT_PATH/.env || true"
71+
]
72+
post_checkout = [
73+
"test -f $WT_MAIN/.env && cp $WT_MAIN/.env $WT_PATH/.env || true"
74+
]
75+
```
76+
77+
This copies `.env` only if it exists in the main checkout. Extend the pattern for other config files (`.env.local`, `config/local.yml`, etc.) by adding more `cp` commands.
78+
6379
## Task spanning multiple repositories
6480

6581
When a task or story requires changes across multiple repositories (e.g. a shared library and a main application), you can organize worktrees by feature instead of by repo using a custom pattern:

0 commit comments

Comments
 (0)