@gw-tools/gw 0.20.12 → 0.20.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +89 -142
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -22,7 +22,7 @@ A command-line tool for managing git worktrees, built with Deno.
22
22
  - [Example Configuration](#example-configuration)
23
23
  - [Configuration Options](#configuration-options)
24
24
  - [Commands](#commands)
25
- - [add](#add)
25
+ - [checkout (add, co)](#checkout)
26
26
  - [Arguments](#arguments)
27
27
  - [Options](#options)
28
28
  - [Examples](#examples)
@@ -32,10 +32,6 @@ A command-line tool for managing git worktrees, built with Deno.
32
32
  - [Arguments](#arguments-1)
33
33
  - [Examples](#examples-1)
34
34
  - [How It Works](#how-it-works)
35
- - [checkout](#checkout)
36
- - [Arguments](#arguments-2)
37
- - [Examples](#examples-2)
38
- - [How It Works](#how-it-works-1)
39
35
  - [pr](#pr)
40
36
  - [Arguments](#arguments-3)
41
37
  - [Options](#options-1)
@@ -124,7 +120,7 @@ gw cd feat/new-feature
124
120
 
125
121
  ```bash
126
122
  # Configure gw in an existing repository
127
- gw init --auto-copy-files .env,secrets/ --post-add "pnpm install"
123
+ gw init --auto-copy-files .env,secrets/ --post-checkout "pnpm install"
128
124
 
129
125
  # Create worktrees - files are copied automatically, dependencies installed
130
126
  gw add feat/another-feature
@@ -165,7 +161,7 @@ Once installed, your AI agent can:
165
161
 
166
162
  ## Initial Setup: Secrets in the Default Branch
167
163
 
168
- **Important:** Before using `gw add` with auto-copy, ensure your secrets and environment files exist in your `defaultBranch` worktree (typically `main`). This worktree is the **source** from which files are copied to new worktrees.
164
+ **Important:** Before using `gw checkout` with auto-copy, ensure your secrets and environment files exist in your `defaultBranch` worktree (typically `main`). This worktree is the **source** from which files are copied to new worktrees.
169
165
 
170
166
  ### First-Time Setup Flow
171
167
 
@@ -203,7 +199,7 @@ gw add feat/new-feature
203
199
  # Clone with configuration in one command
204
200
  gw init git@github.com:user/repo.git \
205
201
  --auto-copy-files .env,secrets/ \
206
- --post-add "pnpm install"
202
+ --post-checkout "pnpm install"
207
203
 
208
204
  # Then set up secrets in main worktree as shown above
209
205
  cd repo.git/main
@@ -213,7 +209,7 @@ cp .env.example .env
213
209
 
214
210
  ### Why This Matters
215
211
 
216
- - **`gw add`** copies files **from** your `defaultBranch` worktree **to** the new worktree
212
+ - **`gw checkout`** copies files **from** your `defaultBranch` worktree **to** the new worktree
217
213
  - **`gw sync`** also uses `defaultBranch` as the source (unless `--from` is specified)
218
214
  - **Auto-clean** will **never** remove the `defaultBranch` worktree, ensuring your source files are always available
219
215
  - If secrets don't exist in `defaultBranch`, they won't be copied to new worktrees
@@ -313,7 +309,7 @@ gw init --root /path/to/your/repo.git
313
309
  // Auto-copy these files when creating new worktrees
314
310
  "autoCopyFiles": [".env", "components/agents/.env", "components/ui/.vercel/"],
315
311
  "hooks": {
316
- "add": {
312
+ "checkout": {
317
313
  "pre": ["echo 'Creating worktree: {worktree}'"],
318
314
  "post": ["pnpm install", "echo 'Setup complete!'"],
319
315
  },
@@ -333,33 +329,46 @@ gw init --root /path/to/your/repo.git
333
329
 
334
330
  - **root**: Absolute path to the git repository root (automatically detected or manually set with `gw init`)
335
331
  - **defaultBranch**: Default source worktree name (optional, defaults to "main")
336
- - **autoCopyFiles**: Array of file/directory paths to automatically copy when creating worktrees with `gw add` (optional, only set via `gw init --auto-copy-files`)
337
- - **hooks**: Command hooks configuration (optional, set via `gw init --pre-add` and `--post-add`)
338
- - **hooks.add.pre**: Array of commands to run before creating a worktree
339
- - **hooks.add.post**: Array of commands to run after creating a worktree
332
+ - **autoCopyFiles**: Array of file/directory paths to automatically copy when creating worktrees with `gw checkout` (optional, only set via `gw init --auto-copy-files`)
333
+ - **hooks**: Command hooks configuration (optional, set via `gw init --pre-checkout` and `--post-checkout`)
334
+ - **hooks.checkout.pre**: Array of commands to run before creating a worktree
335
+ - **hooks.checkout.post**: Array of commands to run after creating a worktree
340
336
  - **cleanThreshold**: Number of days before worktrees are considered stale for `gw clean` (optional, defaults to 7, set via `gw init --clean-threshold`)
341
- - **autoClean**: Prompt to remove stale worktrees when running `gw add` or `gw list` (optional, defaults to false, set via `gw init --auto-clean`)
337
+ - **autoClean**: Prompt to remove stale worktrees when running `gw checkout` or `gw list` (optional, defaults to false, set via `gw init --auto-clean`)
342
338
  - **updateStrategy**: Default strategy for `gw update` command: "merge" or "rebase" (optional, defaults to "merge", set via `gw init --update-strategy`)
343
339
  - **lastAutoCleanTime**: Internal timestamp tracking last auto-cleanup run (managed automatically, do not edit manually)
344
340
 
345
341
  ## Commands
346
342
 
347
- ### add
343
+ ### checkout
344
+
345
+ Create a new git worktree, switch to an existing branch, or navigate to a worktree where a branch is checked out. This is the primary command for working with branches in a worktree workflow.
348
346
 
349
- Create a new git worktree with optional automatic file copying.
347
+ **Aliases:** `co`, `add` (for backwards compatibility)
350
348
 
351
349
  ```bash
352
- gw add <worktree-name> [files...]
350
+ gw checkout <branch-name> [files...]
351
+ # or use aliases
352
+ gw co <branch-name>
353
+ gw add <branch-name> # backwards-compatible alias
353
354
  ```
354
355
 
355
- This command wraps `git worktree add` and optionally copies files to the new worktree. If `autoCopyFiles` is configured, those files are automatically copied. You can override this by specifying files as arguments.
356
+ This unified command handles all branch operations in a worktree workflow:
357
+
358
+ 1. **Branch exists locally, not checked out:** Creates a worktree for it
359
+ 2. **Branch is checked out in another worktree:** Navigates to that worktree
360
+ 3. **Branch exists on remote only:** Prompts to create a worktree for it
361
+ 4. **Branch doesn't exist:** Creates a new branch from the default branch and a worktree for it
362
+ 5. **Already on the branch:** Shows "Already on branch" message
363
+
364
+ If `autoCopyFiles` is configured, those files are automatically copied when creating new worktrees. You can override this by specifying files as arguments.
356
365
 
357
366
  **Branch Creation Behavior:**
358
- When creating a new worktree without specifying an existing branch, `gw add` automatically fetches the latest version of your default branch (e.g., `main`) from the remote (e.g., `origin/main`) to ensure your new branch is based on the most recent code. You can override this with the `--from <branch>` option to create a branch from a different source branch instead.
367
+ When creating a new worktree without specifying an existing branch, `gw checkout` automatically fetches the latest version of your default branch (e.g., `main`) from the remote (e.g., `origin/main`) to ensure your new branch is based on the most recent code. You can override this with the `--from <branch>` option to create a branch from a different source branch instead.
359
368
 
360
369
  **Remote-First Fetch Approach:**
361
370
 
362
- The `gw add` command follows a remote-first approach when creating new branches:
371
+ The `gw checkout` command follows a remote-first approach when creating new branches:
363
372
 
364
373
  1. **What happens**: When you create a new branch (e.g., `gw add feat/new-feature`), the command:
365
374
  - Fetches the latest version of the source branch from the remote (e.g., `origin/main`)
@@ -383,7 +392,7 @@ The `gw add` command follows a remote-first approach when creating new branches:
383
392
  - When no `--from` is specified (using default branch) or when no remote is configured, the command will warn about fetch failures but allow creation using the local branch.
384
393
 
385
394
  **Upstream Tracking:**
386
- When `gw add` creates a new branch, it automatically configures the branch to track `origin/<branch-name>` (e.g., `origin/feat/my-feature`). This means `git push` will push to the correct remote branch without needing to specify `-u origin <branch>` on first push.
395
+ When `gw checkout` creates a new branch, it automatically configures the branch to track `origin/<branch-name>` (e.g., `origin/feat/my-feature`). This means `git push` will push to the correct remote branch without needing to specify `-u origin <branch>` on first push.
387
396
 
388
397
  **Git Ref Conflict Detection:**
389
398
  The command automatically detects and prevents Git ref naming conflicts. For example, you cannot have both a branch named `test` and `test/foo` because Git stores branches as files in `.git/refs/heads/`, and `test` cannot be both a file and a directory. If a conflict is detected, you'll receive a helpful error message with suggestions for resolving it.
@@ -396,7 +405,7 @@ If you try to add a worktree that already exists, the command will prompt you to
396
405
 
397
406
  #### Arguments
398
407
 
399
- - `<worktree-name>`: Name or path for the new worktree
408
+ - `<branch-name>`: Branch name to checkout or create
400
409
  - `[files...]`: Optional files to copy (overrides `autoCopyFiles` config)
401
410
 
402
411
  #### Options
@@ -416,35 +425,46 @@ All `git worktree add` options are supported:
416
425
  #### Examples
417
426
 
418
427
  ```bash
419
- # Create worktree (auto-copies files if autoCopyFiles is configured)
428
+ # Create worktree for new branch (auto-copies files if autoCopyFiles is configured)
420
429
  # Automatically navigates to new worktree
421
- gw add feat/new-feature
430
+ gw checkout feat/new-feature
431
+ gw co feat/new-feature # Using alias
432
+
433
+ # Navigate to worktree where main is already checked out
434
+ gw checkout main
435
+ # Output: Branch main is checked out in another worktree:
436
+ # /path/to/repo/main
437
+ #
438
+ # Navigating there...
422
439
 
423
440
  # Create worktree without navigating to it
424
- gw add feat/new-feature --no-cd
441
+ gw checkout feat/new-feature --no-cd
425
442
 
426
443
  # Create worktree from a different branch instead of defaultBranch
427
- gw add feat/new-feature --from develop
444
+ gw checkout feat/new-feature --from develop
428
445
 
429
446
  # Create child feature branch from parent feature branch
430
- gw add feat/child-feature --from feat/parent-feature
447
+ gw checkout feat/child-feature --from feat/parent-feature
431
448
 
432
449
  # Create worktree with new branch
433
- gw add feat/new-feature -b my-branch
450
+ gw checkout feat/new-feature -b my-branch
434
451
 
435
452
  # Create worktree and copy specific files (overrides config)
436
- gw add feat/new-feature .env secrets/
453
+ gw checkout feat/new-feature .env secrets/
437
454
 
438
455
  # Force create even if branch exists elsewhere
439
- gw add feat/bugfix -f
456
+ gw checkout feat/bugfix -f
440
457
 
441
- # If worktree already exists, prompts to navigate to it
442
- gw add feat/existing-branch
443
- # Output: Worktree feat/existing-branch already exists at:
444
- # /path/to/repo/feat/existing-branch
458
+ # Create worktree for remote branch (prompts)
459
+ gw checkout remote-feature
460
+ # Output: Branch remote-feature exists on remote but not locally.
445
461
  #
446
- # Navigate to it? [Y/n]:
447
- # (Press Enter to navigate, or 'n' to cancel)
462
+ # Create a new worktree for it? [Y/n]:
463
+ # (If yes, creates the worktree)
464
+
465
+ # Already on the branch
466
+ gw checkout current-branch
467
+ # Output: Already on 'current-branch'
448
468
  ```
449
469
 
450
470
  #### Auto-Copy Configuration
@@ -465,21 +485,21 @@ This creates:
465
485
  }
466
486
  ```
467
487
 
468
- Now every time you run `gw add`, these files will be automatically copied from your default source worktree (usually `main`) to the new worktree.
488
+ Now every time you run `gw checkout`, these files will be automatically copied from your default source worktree (usually `main`) to the new worktree.
469
489
 
470
490
  #### Hooks
471
491
 
472
- You can configure pre-add and post-add hooks to run commands before and after worktree creation. This is useful for:
492
+ You can configure pre-checkout and post-checkout hooks to run commands before and after worktree creation. This is useful for:
473
493
 
474
- - **Pre-add hooks**: Running validation scripts, checking prerequisites
475
- - **Post-add hooks**: Installing dependencies, setting up the environment
494
+ - **Pre-checkout hooks**: Running validation scripts, checking prerequisites
495
+ - **Post-checkout hooks**: Installing dependencies, setting up the environment
476
496
 
477
497
  ```bash
478
- # Configure a post-add hook to install dependencies
479
- gw init --post-add "pnpm install"
498
+ # Configure a post-checkout hook to install dependencies
499
+ gw init --post-checkout "pnpm install"
480
500
 
481
501
  # Configure multiple hooks
482
- gw init --pre-add "echo 'Creating: {worktree}'" --post-add "pnpm install" --post-add "echo 'Done!'"
502
+ gw init --pre-checkout "echo 'Creating: {worktree}'" --post-checkout "pnpm install" --post-checkout "echo 'Done!'"
483
503
  ```
484
504
 
485
505
  **Hook Variables:**
@@ -493,17 +513,17 @@ Hooks support variable substitution:
493
513
 
494
514
  **Hook Behavior:**
495
515
 
496
- - **Pre-add hooks** run before the worktree is created (in the git root directory). If any pre-add hook fails, the worktree creation is aborted.
497
- - **Post-add hooks** run after the worktree is created and files are copied (in the new worktree directory). If a post-add hook fails, a warning is shown but the worktree creation is considered successful.
516
+ - **Pre-checkout hooks** run before the worktree is created (in the git root directory). If any pre-checkout hook fails, the worktree creation is aborted.
517
+ - **Post-checkout hooks** run after the worktree is created and files are copied (in the new worktree directory). If a post-checkout hook fails, a warning is shown but the worktree creation is considered successful.
498
518
 
499
519
  **Example: Auto-install dependencies**
500
520
 
501
521
  ```bash
502
522
  # One-time setup
503
- gw init --auto-copy-files .env --post-add "pnpm install"
523
+ gw init --auto-copy-files .env --post-checkout "pnpm install"
504
524
 
505
525
  # Now when you create a worktree:
506
- gw add feat/new-feature
526
+ gw checkout feat/new-feature
507
527
  # 1. Creates the worktree
508
528
  # 2. Copies .env file
509
529
  # 3. Runs pnpm install in the new worktree
@@ -547,79 +567,6 @@ The `cd` command integrates with your shell through an automatically installed f
547
567
 
548
568
  **Note**: Shell integration is automatically installed when you install via npm. If needed, you can manually install or remove it using `gw install-shell`.
549
569
 
550
- ### checkout
551
-
552
- Smart git checkout wrapper that provides an intuitive experience for working with worktrees. The command automatically handles scenarios that would normally cause errors with standard `git checkout`.
553
-
554
- ```bash
555
- gw checkout <branch>
556
- # or use the alias
557
- gw co <branch>
558
- ```
559
-
560
- When you're working with worktrees, you cannot checkout the same branch in multiple worktrees. The `gw checkout` command solves this by detecting when a branch is already checked out elsewhere and navigating you to that worktree instead of showing an error.
561
-
562
- #### Arguments
563
-
564
- - `<branch>`: Branch name to checkout
565
-
566
- #### Examples
567
-
568
- ```bash
569
- # Checkout a local branch (if not checked out elsewhere)
570
- gw checkout feature-x
571
- gw co feature-x # Using alias
572
-
573
- # Navigate to worktree where main is already checked out
574
- gw checkout main
575
- # Output: Branch main is checked out in another worktree:
576
- # /path/to/repo/main
577
- #
578
- # Navigating there...
579
-
580
- # Create worktree for remote branch (prompts)
581
- gw checkout remote-feature
582
- # Output: Branch remote-feature exists on remote but not locally.
583
- #
584
- # Create a new worktree for it? [Y/n]:
585
- # (If yes, runs: gw add remote-feature)
586
-
587
- # Already on the branch
588
- gw checkout current-branch
589
- # Output: Already on 'current-branch'
590
- ```
591
-
592
- #### How It Works
593
-
594
- The `checkout` command intelligently handles four scenarios:
595
-
596
- 1. **Branch exists locally and isn't checked out anywhere:**
597
- - Performs standard `git checkout <branch>` in the current worktree
598
-
599
- 2. **Branch is already checked out in another worktree:**
600
- - Automatically navigates to that worktree (like `gw cd`)
601
- - Shows you where the branch is located
602
-
603
- 3. **Branch exists on remote but not locally:**
604
- - Prompts you to create a new worktree for it
605
- - If you confirm, runs `gw add <branch>` which:
606
- - Creates the worktree
607
- - Copies auto-copy files
608
- - Navigates to the new worktree
609
-
610
- 4. **Branch doesn't exist anywhere:**
611
- - Shows a helpful error message
612
- - Suggests using `gw add <branch>` to create a new branch
613
-
614
- **Why use this instead of `git checkout`?**
615
-
616
- - **No more confusing errors:** Instead of "fatal: 'main' is already checked out at '/path/to/main'", it just takes you there
617
- - **Reduces mental overhead:** You don't need to remember which branches are where
618
- - **Teaches worktree workflows:** The messages guide you toward the right action
619
- - **Educational:** Prompts explain what's happening and suggest alternatives
620
-
621
- **Use case:** When updating your feature branch with latest changes, you might instinctively try `git checkout main && git pull`. With worktrees, this fails because main is checked out elsewhere. Instead, use `gw update` to update your current branch with main, or use `gw checkout main` to navigate to the main worktree.
622
-
623
570
  ### pr
624
571
 
625
572
  Check out a pull request into a new worktree. This command fetches a PR's branch and creates a worktree for it in one step, making it easy to review, test, or contribute to pull requests.
@@ -676,8 +623,8 @@ gw pr 42 --no-cd
676
623
  3. **Checks for existing worktree**: If the branch is already checked out, offers to navigate there
677
624
  4. **Fetches PR branch**: Uses `git fetch origin pull/<number>/head:<branch>` pattern which works for both same-repo and fork PRs
678
625
  5. **Creates worktree**: Creates a new worktree with the PR's branch
679
- 6. **Copies files**: Auto-copies files from `autoCopyFiles` config (same as `gw add`)
680
- 7. **Runs hooks**: Executes pre-add and post-add hooks (same as `gw add`)
626
+ 6. **Copies files**: Auto-copies files from `autoCopyFiles` config (same as `gw checkout`)
627
+ 7. **Runs hooks**: Executes pre-checkout and post-checkout hooks (same as `gw checkout`)
681
628
  8. **Navigates**: Automatically navigates to the new worktree
682
629
 
683
630
  **Fork Handling:**
@@ -786,7 +733,7 @@ Shell integration provides:
786
733
 
787
734
  - **Navigation support**: `gw cd <worktree>` navigates directly to worktrees
788
735
  - **Real-time streaming**: Command output streams as it's generated (no buffering)
789
- - **Auto-navigation**: Automatically navigate after `gw add` and `gw remove` operations
736
+ - **Auto-navigation**: Automatically navigate after `gw checkout` and `gw remove` operations
790
737
  - **Multi-alias support**: Install for different command names (e.g., `gw-dev` for development)
791
738
 
792
739
  ```bash
@@ -884,11 +831,11 @@ gw init [repository-url] [directory] [options]
884
831
  - `-i, --interactive`: Interactively prompt for configuration options
885
832
  - `--root <path>`: Specify the git repository root path (optional, auto-detects if not provided)
886
833
  - `--default-source <name>`: Set the default source worktree (default: "main")
887
- - `--auto-copy-files <files>`: Comma-separated list of files to auto-copy when creating worktrees with `gw add`
888
- - `--pre-add <command>`: Command to run before `gw add` creates a worktree (can be specified multiple times)
889
- - `--post-add <command>`: Command to run after `gw add` creates a worktree (can be specified multiple times)
834
+ - `--auto-copy-files <files>`: Comma-separated list of files to auto-copy when creating worktrees with `gw checkout`
835
+ - `--pre-checkout <command>`: Command to run before `gw checkout` creates a worktree (can be specified multiple times)
836
+ - `--post-checkout <command>`: Command to run after `gw checkout` creates a worktree (can be specified multiple times)
890
837
  - `--clean-threshold <days>`: Number of days before worktrees are considered stale for `gw clean` (default: 7)
891
- - `--auto-clean`: Enable automatic cleanup of stale worktrees (runs on `gw add` and `gw list` with 24-hour cooldown)
838
+ - `--auto-clean`: Enable automatic cleanup of stale worktrees (runs on `gw checkout` and `gw list` with 24-hour cooldown)
892
839
  - `--update-strategy <strategy>`: Set default update strategy: 'merge' or 'rebase' (default: merge)
893
840
  - `-h, --help`: Show help message
894
841
 
@@ -901,7 +848,7 @@ Clone a repository and automatically set it up with gw configuration. **This is
901
848
  gw init git@github.com:user/repo.git --interactive
902
849
  # Prompts for:
903
850
  # - Auto-copy files (.env, secrets/, etc.)
904
- # - Pre-add and post-add hooks (pnpm install, etc.)
851
+ # - Pre-checkout and post-checkout hooks (pnpm install, etc.)
905
852
  # - Clean threshold
906
853
  # - Update strategy
907
854
  # Then automatically creates the main worktree and navigates to the repo
@@ -909,7 +856,7 @@ gw init git@github.com:user/repo.git --interactive
909
856
  # Clone with configuration in one command (non-interactive)
910
857
  gw init git@github.com:user/repo.git \
911
858
  --auto-copy-files .env,secrets/ \
912
- --post-add "pnpm install"
859
+ --post-checkout "pnpm install"
913
860
 
914
861
  # Clone into specific directory
915
862
  gw init git@github.com:user/repo.git my-project --interactive
@@ -934,7 +881,7 @@ gw init git@github.com:user/repo.git
934
881
 
935
882
  - No need to manually run `git clone --bare` or `git worktree add`
936
883
  - Configuration is set up immediately
937
- - Ready to use `gw add` right away
884
+ - Ready to use `gw checkout` right away
938
885
 
939
886
  **Notes:**
940
887
 
@@ -958,13 +905,13 @@ gw init
958
905
  gw init --auto-copy-files .env,secrets/
959
906
 
960
907
  # Initialize with post-add hook to install dependencies
961
- gw init --post-add "pnpm install"
908
+ gw init --post-checkout "pnpm install"
962
909
 
963
910
  # Initialize with pre-add validation hook
964
- gw init --pre-add "echo 'Creating worktree: {worktree}'"
911
+ gw init --pre-checkout "echo 'Creating worktree: {worktree}'"
965
912
 
966
913
  # Initialize with multiple hooks
967
- gw init --pre-add "echo 'Starting...'" --post-add "pnpm install" --post-add "echo 'Done!'"
914
+ gw init --pre-checkout "echo 'Starting...'" --post-checkout "pnpm install" --post-checkout "echo 'Done!'"
968
915
 
969
916
  # Initialize with custom default source
970
917
  gw init --default-source master
@@ -979,7 +926,7 @@ gw init --clean-threshold 14
979
926
  gw init --update-strategy rebase
980
927
 
981
928
  # Full configuration example
982
- gw init --auto-copy-files .env,secrets/ --post-add "pnpm install" --clean-threshold 14 --update-strategy merge
929
+ gw init --auto-copy-files .env,secrets/ --post-checkout "pnpm install" --clean-threshold 14 --update-strategy merge
983
930
 
984
931
  # Show help
985
932
  gw init --help
@@ -1006,12 +953,12 @@ gw init --auto-clean
1006
953
  gw init --auto-clean --clean-threshold 14
1007
954
 
1008
955
  # Enable with other options
1009
- gw init --auto-clean --auto-copy-files .env --post-add "pnpm install"
956
+ gw init --auto-clean --auto-copy-files .env --post-checkout "pnpm install"
1010
957
  ```
1011
958
 
1012
959
  **How it works:**
1013
960
 
1014
- - Prompts after `gw add` and `gw list` commands when stale worktrees are detected
961
+ - Prompts after `gw checkout` and `gw list` commands when stale worktrees are detected
1015
962
  - Only prompts once per 24 hours (cooldown)
1016
963
  - **Never removes the `defaultBranch` worktree** - it's protected as the source for file syncing
1017
964
  - Checks for worktrees older than `cleanThreshold` with:
@@ -1081,7 +1028,7 @@ If your `.gw/config.json` contains:
1081
1028
  "defaultBranch": "main",
1082
1029
  "autoCopyFiles": [".env", "secrets/"],
1083
1030
  "hooks": {
1084
- "add": {
1031
+ "checkout": {
1085
1032
  "post": ["pnpm install"]
1086
1033
  }
1087
1034
  },
@@ -1093,7 +1040,7 @@ If your `.gw/config.json` contains:
1093
1040
  Then `gw show-init` will output:
1094
1041
 
1095
1042
  ```bash
1096
- gw init --root /Users/username/Workspace/repo.git --auto-copy-files .env,secrets/ --post-add 'pnpm install' --update-strategy rebase
1043
+ gw init --root /Users/username/Workspace/repo.git --auto-copy-files .env,secrets/ --post-checkout 'pnpm install' --update-strategy rebase
1097
1044
  ```
1098
1045
 
1099
1046
  #### When to Use
@@ -1444,7 +1391,7 @@ gw cd feat/new-feature
1444
1391
  ```bash
1445
1392
  # One-time setup: Configure auto-copy files and hooks
1446
1393
  gw init --auto-copy-files .env,components/agents/.env,components/ui/.vercel/ \
1447
- --post-add "pnpm install"
1394
+ --post-checkout "pnpm install"
1448
1395
 
1449
1396
  # From within any worktree of your repository
1450
1397
  # Create a new worktree with auto-copy and hooks
@@ -1667,7 +1614,7 @@ packages/gw-tool/
1667
1614
  │ ├── main.ts # CLI entry point and command dispatcher
1668
1615
  │ ├── index.ts # Public API exports
1669
1616
  │ ├── commands/ # Command implementations
1670
- │ │ ├── add.ts # Add command (create worktree with auto-copy)
1617
+ │ │ ├── checkout.ts # Checkout command (create worktree, switch branches, navigate)
1671
1618
  │ │ ├── copy.ts # Sync command (sync files between worktrees)
1672
1619
  │ │ ├── init.ts # Init command
1673
1620
  │ │ ├── root.ts # Root command
@@ -1702,7 +1649,7 @@ packages/gw-tool/
1702
1649
 
1703
1650
  There are two types of commands you can add:
1704
1651
 
1705
- #### Custom Commands (like `add`, `copy`)
1652
+ #### Custom Commands (like `checkout`, `sync`)
1706
1653
 
1707
1654
  For commands with custom logic, follow the pattern used by existing commands:
1708
1655
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw-tools/gw",
3
- "version": "0.20.12",
3
+ "version": "0.20.13",
4
4
  "description": "A command-line tool for managing git worktrees - copy files between worktrees with ease",
5
5
  "keywords": [
6
6
  "git",