@gw-tools/gw 0.15.1 → 0.16.1-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.
- package/README.md +61 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -291,7 +291,11 @@ gw add <worktree-name> [files...]
|
|
|
291
291
|
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.
|
|
292
292
|
|
|
293
293
|
**Branch Creation Behavior:**
|
|
294
|
-
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.
|
|
294
|
+
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.
|
|
295
|
+
|
|
296
|
+
**Network Failure Handling:**
|
|
297
|
+
- When using `--from` with an explicit branch, the command requires a successful fetch from the remote to ensure you're working with the latest code. If the fetch fails (network issues, branch doesn't exist on remote, authentication problems), the command will exit with a detailed error message and suggestions for resolution.
|
|
298
|
+
- 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.
|
|
295
299
|
|
|
296
300
|
**Upstream Tracking:**
|
|
297
301
|
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.
|
|
@@ -313,6 +317,7 @@ If you try to add a worktree that already exists, the command will prompt you to
|
|
|
313
317
|
#### Options
|
|
314
318
|
|
|
315
319
|
- `--no-cd`: Don't navigate to the new worktree after creation
|
|
320
|
+
- `--from <branch>`: Create new branch from specified branch instead of `defaultBranch`
|
|
316
321
|
|
|
317
322
|
All `git worktree add` options are supported:
|
|
318
323
|
|
|
@@ -333,6 +338,12 @@ gw add feat/new-feature
|
|
|
333
338
|
# Create worktree without navigating to it
|
|
334
339
|
gw add feat/new-feature --no-cd
|
|
335
340
|
|
|
341
|
+
# Create worktree from a different branch instead of defaultBranch
|
|
342
|
+
gw add feat/new-feature --from develop
|
|
343
|
+
|
|
344
|
+
# Create child feature branch from parent feature branch
|
|
345
|
+
gw add feat/child-feature --from feat/parent-feature
|
|
346
|
+
|
|
336
347
|
# Create worktree with new branch
|
|
337
348
|
gw add feat/new-feature -b my-branch
|
|
338
349
|
|
|
@@ -584,6 +595,11 @@ gw update --remote upstream
|
|
|
584
595
|
- Blocks if you're in a detached HEAD state
|
|
585
596
|
- Handles merge/rebase conflicts gracefully with clear guidance
|
|
586
597
|
|
|
598
|
+
**Network Failure Handling:**
|
|
599
|
+
|
|
600
|
+
- When using `--from` with an explicit branch, the command requires a successful fetch from the remote to ensure you're updating with the latest code. If the fetch fails (network issues, branch doesn't exist on remote, authentication problems), the command will exit with a detailed error message and suggestions for resolution.
|
|
601
|
+
- When no `--from` is specified (using default branch) or when no remote is configured, the command will warn about fetch failures but allow the update using the local branch.
|
|
602
|
+
|
|
587
603
|
**Update strategy:**
|
|
588
604
|
|
|
589
605
|
The strategy can be configured in `.gw/config.json` or overridden per-command:
|
|
@@ -698,10 +714,12 @@ gw root
|
|
|
698
714
|
|
|
699
715
|
### init
|
|
700
716
|
|
|
701
|
-
Initialize gw configuration for a git repository. This command
|
|
717
|
+
Initialize gw configuration for a git repository. This command can:
|
|
718
|
+
1. **Clone mode**: Clone a repository and set it up with gw configuration
|
|
719
|
+
2. **Existing repo mode**: Initialize gw in an existing repository
|
|
702
720
|
|
|
703
721
|
```bash
|
|
704
|
-
gw init [options]
|
|
722
|
+
gw init [repository-url] [directory] [options]
|
|
705
723
|
```
|
|
706
724
|
|
|
707
725
|
#### Options
|
|
@@ -717,10 +735,47 @@ gw init [options]
|
|
|
717
735
|
- `--update-strategy <strategy>`: Set default update strategy: 'merge' or 'rebase' (default: merge)
|
|
718
736
|
- `-h, --help`: Show help message
|
|
719
737
|
|
|
720
|
-
#### Examples
|
|
738
|
+
#### Clone Examples
|
|
739
|
+
|
|
740
|
+
Clone a repository and automatically set up gw configuration:
|
|
741
|
+
|
|
742
|
+
```bash
|
|
743
|
+
# Clone and initialize (auto-derive directory name from repository)
|
|
744
|
+
gw init git@github.com:user/repo.git
|
|
745
|
+
|
|
746
|
+
# Clone into specific directory
|
|
747
|
+
gw init git@github.com:user/repo.git my-project
|
|
748
|
+
|
|
749
|
+
# Clone with HTTPS URL
|
|
750
|
+
gw init https://github.com/user/repo.git
|
|
751
|
+
|
|
752
|
+
# Clone and configure interactively
|
|
753
|
+
gw init git@github.com:user/repo.git --interactive
|
|
754
|
+
|
|
755
|
+
# Clone with auto-copy files configured
|
|
756
|
+
gw init git@github.com:user/repo.git --auto-copy-files .env,secrets/
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
When cloning, `gw init` will:
|
|
760
|
+
1. Clone the repository with `--no-checkout`
|
|
761
|
+
2. Create a `gw_root` branch
|
|
762
|
+
3. Auto-detect the default branch from the remote
|
|
763
|
+
4. Create gw configuration
|
|
764
|
+
5. Create the default branch worktree
|
|
765
|
+
6. Automatically navigate to the repository directory (requires shell integration)
|
|
766
|
+
|
|
767
|
+
**Notes**:
|
|
768
|
+
- Cloned repositories use the `.git` suffix (e.g., `repo.git`) following bare repository conventions
|
|
769
|
+
- After cloning, you'll be automatically navigated to the repository root where you can run gw commands
|
|
770
|
+
- Shell integration must be installed (`gw install-shell`) for automatic navigation to work
|
|
771
|
+
|
|
772
|
+
#### Existing Repository Examples
|
|
773
|
+
|
|
774
|
+
Initialize gw in an existing repository:
|
|
721
775
|
|
|
722
776
|
```bash
|
|
723
777
|
# Interactive mode - prompts for all configuration options
|
|
778
|
+
# If not in a git repo, will first prompt for repository URL to clone
|
|
724
779
|
gw init --interactive
|
|
725
780
|
|
|
726
781
|
# Initialize with auto-detected root
|
|
@@ -925,6 +980,8 @@ gw sync /full/path/to/repo/feat-branch .env
|
|
|
925
980
|
|
|
926
981
|
Remove safe worktrees with no uncommitted changes and no unpushed commits. By default, removes **ALL** safe worktrees regardless of age. Use `--use-autoclean-threshold` to only remove worktrees older than the configured threshold.
|
|
927
982
|
|
|
983
|
+
**Automatic Pruning:** The clean command automatically runs `git worktree prune` before listing worktrees, ensuring only worktrees that actually exist on disk are shown. This prevents "phantom" worktrees (manually deleted directories) from appearing in the list.
|
|
984
|
+
|
|
928
985
|
**Note:** For automatic cleanup, see `gw init --auto-clean`. The `clean` command provides interactive, manual cleanup with detailed output and confirmation prompts.
|
|
929
986
|
|
|
930
987
|
```bash
|