@gw-tools/gw 0.35.0 → 0.37.0-beta.34.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 +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -431,6 +431,7 @@ If you try to add a worktree that already exists, the command will prompt you to
|
|
|
431
431
|
|
|
432
432
|
- `--no-cd`: Don't navigate to the new worktree after creation
|
|
433
433
|
- `--from <branch>`: Create new branch from specified branch instead of `defaultBranch`
|
|
434
|
+
- `--from-staged`: Copy staged files from current worktree to new worktree (see [Staged Files](#staged-files))
|
|
434
435
|
|
|
435
436
|
All `git worktree add` options are supported:
|
|
436
437
|
|
|
@@ -484,8 +485,45 @@ gw checkout remote-feature
|
|
|
484
485
|
# Already on the branch
|
|
485
486
|
gw checkout current-branch
|
|
486
487
|
# Output: Already on 'current-branch'
|
|
488
|
+
|
|
489
|
+
# Extract staged files to a new worktree
|
|
490
|
+
gw checkout feat/extracted-work --from-staged
|
|
491
|
+
# Output: Copies all staged files from current worktree to new worktree
|
|
492
|
+
|
|
493
|
+
# Extract specific staged files
|
|
494
|
+
gw checkout feat/extracted-work --from-staged src/new-feature.ts tests/
|
|
495
|
+
# Output: Only copies the specified files (if they are staged)
|
|
487
496
|
```
|
|
488
497
|
|
|
498
|
+
#### Staged Files
|
|
499
|
+
|
|
500
|
+
The `--from-staged` flag allows you to extract staged changes from your current worktree into a new worktree. This is useful when you've started work that belongs in a different branch:
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# 1. Stage the files you want to extract
|
|
504
|
+
git add src/new-feature.ts tests/new-feature.test.ts
|
|
505
|
+
|
|
506
|
+
# 2. Create new worktree with staged files
|
|
507
|
+
gw checkout feat/new-feature --from-staged
|
|
508
|
+
|
|
509
|
+
# 3. Your staged files are now in the new worktree
|
|
510
|
+
# The original worktree is unchanged (files remain staged)
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**Behavior:**
|
|
514
|
+
|
|
515
|
+
- **All staged files**: `gw checkout <branch> --from-staged` copies all staged files
|
|
516
|
+
- **Specific files**: `gw checkout <branch> --from-staged file1 file2` only copies those files (must be staged)
|
|
517
|
+
- **autoCopyFiles still applies**: Config files like `.env` are still copied alongside staged files
|
|
518
|
+
- **Deleted files skipped**: Files staged for deletion are skipped (nothing to copy)
|
|
519
|
+
- **Atomic operation**: If any file fails to copy, the worktree is removed
|
|
520
|
+
|
|
521
|
+
**Use cases:**
|
|
522
|
+
|
|
523
|
+
- Started feature work but realized it should be a separate branch
|
|
524
|
+
- Need to split a large PR into smaller pieces
|
|
525
|
+
- Want to test changes in isolation without committing first
|
|
526
|
+
|
|
489
527
|
#### Auto-Copy Configuration
|
|
490
528
|
|
|
491
529
|
To enable automatic file copying, configure `autoCopyFiles` using `gw init`:
|