@gw-tools/gw 0.13.16 → 0.14.3-beta.1

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 +61 -32
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -35,7 +35,7 @@ A command-line tool for managing git worktrees, built with Deno.
35
35
  - [Arguments](#arguments-2)
36
36
  - [Examples](#examples-2)
37
37
  - [How It Works](#how-it-works-1)
38
- - [pull](#pull)
38
+ - [update](#update)
39
39
  - [Options](#options-1)
40
40
  - [Examples](#examples-3)
41
41
  - [How It Works](#how-it-works-2)
@@ -258,6 +258,7 @@ gw init --root /path/to/your/repo.git
258
258
  },
259
259
  "cleanThreshold": 7,
260
260
  "autoClean": true,
261
+ "updateStrategy": "merge",
261
262
  "lastAutoCleanTime": 1706371200000
262
263
  }
263
264
  ```
@@ -273,7 +274,8 @@ gw init --root /path/to/your/repo.git
273
274
  - **hooks.add.pre**: Array of commands to run before creating a worktree
274
275
  - **hooks.add.post**: Array of commands to run after creating a worktree
275
276
  - **cleanThreshold**: Number of days before worktrees are considered stale for `gw clean` (optional, defaults to 7, set via `gw init --clean-threshold`)
276
- - **autoClean**: Automatically remove stale worktrees when running `gw add` or `gw list` (optional, defaults to false, set via `gw init --auto-clean`)
277
+ - **autoClean**: Prompt to remove stale worktrees when running `gw add` or `gw list` (optional, defaults to false, set via `gw init --auto-clean`)
278
+ - **updateStrategy**: Default strategy for `gw update` command: "merge" or "rebase" (optional, defaults to "merge", set via `gw init --update-strategy`)
277
279
  - **lastAutoCleanTime**: Internal timestamp tracking last auto-cleanup run (managed automatically, do not edit manually)
278
280
 
279
281
  ## Commands
@@ -520,24 +522,26 @@ The `checkout` command intelligently handles four scenarios:
520
522
  - **Teaches worktree workflows:** The messages guide you toward the right action
521
523
  - **Educational:** Prompts explain what's happening and suggest alternatives
522
524
 
523
- **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 pull` to merge main into your current branch, or use `gw checkout main` to navigate to the main worktree.
525
+ **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.
524
526
 
525
- ### pull
527
+ ### update
526
528
 
527
- Merge the latest version of the default branch (or specified branch) into your current worktree. This is useful when you want to update your feature branch with the latest changes from main without having to switch worktrees.
529
+ Update your current worktree with the latest changes from the default branch (or specified branch) using either merge or rebase strategy. This is useful when you want to update your feature branch with the latest changes from main without having to switch worktrees.
528
530
 
529
531
  ```bash
530
- gw pull [options]
532
+ gw update [options]
531
533
  ```
532
534
 
533
- When working in a worktree, you cannot easily checkout main to pull the latest changes because main is typically checked out in another worktree. The `gw pull` command solves this by fetching the latest version of the default branch and merging it into your current branch.
535
+ When working in a worktree, you cannot easily checkout main to pull the latest changes because main is typically checked out in another worktree. The `gw update` command solves this by fetching the latest version of the default branch and updating your current branch using your configured strategy (merge or rebase).
534
536
 
535
537
  **Alternative:** If you need to work on the main branch directly, use `gw checkout main` to navigate to the main worktree instead of trying to check it out in your current worktree.
536
538
 
537
539
  #### Options
538
540
 
539
- - `--from <branch>`: Merge from specified branch instead of defaultBranch (e.g., `--from develop`)
541
+ - `--from <branch>`: Update from specified branch instead of defaultBranch (e.g., `--from develop`)
540
542
  - `--remote <name>`: Specify remote name (default: "origin")
543
+ - `-m, --merge`: Force merge strategy (overrides configured strategy)
544
+ - `-r, --rebase`: Force rebase strategy (overrides configured strategy)
541
545
  - `-f, --force`: Skip uncommitted changes check (not recommended)
542
546
  - `-n, --dry-run`: Preview what would happen without executing
543
547
  - `-h, --help`: Show help message
@@ -545,47 +549,62 @@ When working in a worktree, you cannot easily checkout main to pull the latest c
545
549
  #### Examples
546
550
 
547
551
  ```bash
548
- # Merge latest default branch (typically main)
549
- gw pull
552
+ # Update with configured strategy (or merge if not configured)
553
+ gw update
550
554
 
551
- # Merge from a specific branch
552
- gw pull --from develop
555
+ # Force merge even if rebase is configured
556
+ gw update --merge
557
+
558
+ # Force rebase even if merge is configured
559
+ gw update --rebase
560
+
561
+ # Update from a specific branch
562
+ gw update --from develop
553
563
 
554
564
  # Preview what would happen
555
- gw pull --dry-run
565
+ gw update --dry-run
556
566
 
557
- # Force pull even with uncommitted changes (not recommended)
558
- gw pull --force
567
+ # Force update even with uncommitted changes (not recommended)
568
+ gw update --force
559
569
 
560
570
  # Use a different remote
561
- gw pull --remote upstream
571
+ gw update --remote upstream
562
572
  ```
563
573
 
564
574
  #### How It Works
565
575
 
566
576
  1. Fetches the latest version of the target branch from remote (e.g., `origin/main`)
567
- 2. Merges it into your current worktree's active branch
568
- 3. Creates merge commit if histories have diverged
577
+ 2. Updates your current worktree's active branch using the configured strategy
578
+ 3. With **merge**: Creates merge commit if histories have diverged
579
+ 4. With **rebase**: Replays your commits on top of the latest changes
569
580
 
570
581
  **Safety checks:**
571
582
 
572
583
  - Blocks if you have uncommitted changes (use `--force` to override)
573
584
  - Blocks if you're in a detached HEAD state
574
- - Handles merge conflicts gracefully with clear guidance
585
+ - Handles merge/rebase conflicts gracefully with clear guidance
586
+
587
+ **Update strategy:**
588
+
589
+ The strategy can be configured in `.gw/config.json` or overridden per-command:
575
590
 
576
- **Merge strategy:** Allows merge commits (not fast-forward only), so it works even if you have local commits.
591
+ - **merge** (default): Creates merge commits, preserves complete history
592
+ - **rebase**: Replays commits for linear history, cleaner but rewrites history
593
+
594
+ Strategy precedence: CLI flags (`--merge`/`--rebase`) > config (`updateStrategy`) > default (merge)
577
595
 
578
596
  **Configuration:**
579
597
 
580
- The default branch is read from `.gw/config.json`:
598
+ The default branch and update strategy are read from `.gw/config.json`:
581
599
 
582
600
  ```json
583
601
  {
584
- "defaultBranch": "main"
602
+ "defaultBranch": "main",
603
+ "updateStrategy": "merge"
585
604
  }
586
605
  ```
587
606
 
588
- If not configured, defaults to "main".
607
+ If not configured, defaults to "main" branch and "merge" strategy.
589
608
 
590
609
  ### install-shell
591
610
 
@@ -695,6 +714,7 @@ gw init [options]
695
714
  - `--post-add <command>`: Command to run after `gw add` creates a worktree (can be specified multiple times)
696
715
  - `--clean-threshold <days>`: Number of days before worktrees are considered stale for `gw clean` (default: 7)
697
716
  - `--auto-clean`: Enable automatic cleanup of stale worktrees (runs on `gw add` and `gw list` with 24-hour cooldown)
717
+ - `--update-strategy <strategy>`: Set default update strategy: 'merge' or 'rebase' (default: merge)
698
718
  - `-h, --help`: Show help message
699
719
 
700
720
  #### Examples
@@ -727,8 +747,11 @@ gw init --root /Users/username/Workspace/my-project.git
727
747
  # Initialize with custom clean threshold (14 days instead of default 7)
728
748
  gw init --clean-threshold 14
729
749
 
750
+ # Initialize with update strategy
751
+ gw init --update-strategy rebase
752
+
730
753
  # Full configuration example
731
- gw init --auto-copy-files .env,secrets/ --post-add "pnpm install" --clean-threshold 14
754
+ gw init --auto-copy-files .env,secrets/ --post-add "pnpm install" --clean-threshold 14 --update-strategy merge
732
755
 
733
756
  # Show help
734
757
  gw init --help
@@ -745,7 +768,7 @@ Hooks support variable substitution:
745
768
 
746
769
  #### Auto-Cleanup Configuration
747
770
 
748
- Enable automatic removal of stale worktrees to keep your repository clean:
771
+ Enable interactive cleanup prompts for stale worktrees to keep your repository clean:
749
772
 
750
773
  ```bash
751
774
  # Enable auto-cleanup with default 7-day threshold
@@ -760,14 +783,19 @@ gw init --auto-clean --auto-copy-files .env --post-add "pnpm install"
760
783
 
761
784
  **How it works:**
762
785
 
763
- - Runs automatically on `gw add` and `gw list` commands (in the background, non-blocking)
764
- - Only runs once per 24 hours (cooldown)
786
+ - Prompts after `gw add` and `gw list` commands when stale worktrees are detected
787
+ - Only prompts once per 24 hours (cooldown)
765
788
  - **Never removes the `defaultBranch` worktree** - it's protected as the source for file syncing
766
- - Removes worktrees older than `cleanThreshold` with:
789
+ - Checks for worktrees older than `cleanThreshold` with:
767
790
  - No uncommitted changes
768
791
  - No staged files
769
792
  - No unpushed commits
770
- - Shows brief message only when worktrees are removed: `🧹 Auto-cleanup: Removed 2 stale worktrees`
793
+ - Shows interactive prompt when stale worktrees are found:
794
+ ```
795
+ 🧹 Found 2 stale worktrees (7+ days old). Clean them up? [Y/n]:
796
+ ```
797
+ - Press Enter or `y` to remove them, or `n` to skip
798
+ - Shows brief summary after cleanup: `✓ Removed 2 stale worktrees`
771
799
  - Never interrupts or fails the main command
772
800
 
773
801
  This is an opt-in feature. Use `gw clean` for manual, interactive cleanup with more control.
@@ -829,14 +857,15 @@ If your `.gw/config.json` contains:
829
857
  "post": ["pnpm install"]
830
858
  }
831
859
  },
832
- "cleanThreshold": 7
860
+ "cleanThreshold": 7,
861
+ "updateStrategy": "rebase"
833
862
  }
834
863
  ```
835
864
 
836
865
  Then `gw show-init` will output:
837
866
 
838
867
  ```bash
839
- gw init --root /Users/username/Workspace/repo.git --auto-copy-files .env,secrets/ --post-add 'pnpm install'
868
+ gw init --root /Users/username/Workspace/repo.git --auto-copy-files .env,secrets/ --post-add 'pnpm install' --update-strategy rebase
840
869
  ```
841
870
 
842
871
  #### When to Use
@@ -1134,7 +1163,7 @@ gw add feat-new-feature
1134
1163
  gw cd feat-new-feature
1135
1164
 
1136
1165
  # Keep your feature branch updated with latest changes from main
1137
- gw pull
1166
+ gw update
1138
1167
 
1139
1168
  # Navigate to main worktree (if you need to work on it)
1140
1169
  gw checkout main # or gw co main
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw-tools/gw",
3
- "version": "0.13.16",
3
+ "version": "0.14.3-beta.1",
4
4
  "description": "A command-line tool for managing git worktrees - copy files between worktrees with ease",
5
5
  "keywords": [
6
6
  "git",