adding.md

 1# Adding Worktrees
 2
 3## Basic Usage
 4
 5```bash
 6wt a <branch> [-b [<start-point>]]
 7```
 8
 9## Examples
10
11```bash
12wt a main                    # checkout existing branch
13wt a feature/new -b          # create new branch from HEAD
14wt a feature/new -b main     # create new branch from main
15wt a feature/new -b v1.0.0   # create new branch from tag
16```
17
18## Hooks
19
20When `wt a` runs **from inside an existing worktree**, hooks from `.wt.lua` are applied to the new worktree.
21
22Running from project root skips hooks with a warning.
23
24### Hook Types
25
26| Hook      | Purpose                                  |
27| --------- | ---------------------------------------- |
28| `copy`    | Copy files from source worktree          |
29| `symlink` | Create symlinks to source worktree files |
30| `run`     | Execute shell commands in new worktree   |
31
32### Example `.wt.lua`
33
34```lua
35return {
36    hooks = {
37        copy = {"Makefile", "*.mk"},
38        symlink = {".env", "config.toml", "node_modules"},
39        run = {"make setup", "npm install"}
40    }
41}
42```
43
44### Hook Permissions
45
46First time hooks run in a project, `wt` prompts for permission via `gum confirm`. Permissions stored in `~/.local/share/wt/hook-dirs.lua`.
47
48## Branch Resolution
49
50When adding without `-b`:
51
521. Checks local branches
532. Checks all remotes
543. Fails if branch exists on multiple remotes (ambiguous)
55
56## Path Styles
57
58Configured in `~/.config/wt/config.lua`:
59
60| Style              | Example Branch | Result Path           |
61| ------------------ | -------------- | --------------------- |
62| `nested` (default) | `feature/foo`  | `project/feature/foo` |
63| `flat`             | `feature/foo`  | `project_feature_foo` |
64
65```lua
66return {
67    branch_path_style = "flat",
68    flat_separator = "_"
69}
70```