@gw-tools/gw 0.20.9-beta.1 → 0.20.12-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 +30 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -315,13 +315,13 @@ gw init --root /path/to/your/repo.git
|
|
|
315
315
|
"hooks": {
|
|
316
316
|
"add": {
|
|
317
317
|
"pre": ["echo 'Creating worktree: {worktree}'"],
|
|
318
|
-
"post": ["pnpm install", "echo 'Setup complete!'"]
|
|
319
|
-
}
|
|
318
|
+
"post": ["pnpm install", "echo 'Setup complete!'"],
|
|
319
|
+
},
|
|
320
320
|
},
|
|
321
321
|
"cleanThreshold": 7,
|
|
322
322
|
"autoClean": true,
|
|
323
323
|
"updateStrategy": "merge",
|
|
324
|
-
"lastAutoCleanTime": 1706371200000,
|
|
324
|
+
"lastAutoCleanTime": 1706371200000, // trailing comma OK
|
|
325
325
|
}
|
|
326
326
|
```
|
|
327
327
|
|
|
@@ -354,33 +354,27 @@ gw add <worktree-name> [files...]
|
|
|
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
356
|
|
|
357
|
-
**Branch
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
**Remote-First Fetch Approach:**
|
|
357
|
+
**Branch Handling:**
|
|
358
|
+
`gw add` intelligently handles different branch scenarios:
|
|
361
359
|
|
|
362
|
-
|
|
360
|
+
1. **Local branches**: If the branch already exists locally, it's used directly. No network access required.
|
|
363
361
|
|
|
364
|
-
|
|
365
|
-
- Fetches the latest version of the source branch from the remote (e.g., `origin/main`)
|
|
366
|
-
- Creates your new branch from the fresh remote ref (e.g., `origin/main`)
|
|
367
|
-
- Sets up tracking to `origin/feat/new-feature` for easy pushing
|
|
362
|
+
2. **Remote-only branches**: If the branch exists only on remote (e.g., `origin/feat/something`), `gw add` fetches it and creates a proper local tracking branch. This ensures `git push` and `git pull` work correctly.
|
|
368
363
|
|
|
369
|
-
|
|
370
|
-
- Merge conflicts from missing recent changes
|
|
371
|
-
- Building features on old code
|
|
372
|
-
- Divergent histories that are hard to reconcile
|
|
364
|
+
3. **New branches**: If the branch doesn't exist anywhere, it's created from the source branch (defaultBranch or `--from` branch) after fetching the latest from remote.
|
|
373
365
|
|
|
374
|
-
|
|
375
|
-
- **With `--from <branch>`**: Requires successful remote fetch. If the fetch fails (network issues, branch doesn't exist on remote, authentication problems), the command exits with a detailed error message and troubleshooting steps. This ensures you're working with fresh code when you explicitly specify a source.
|
|
376
|
-
- **Without `--from` (default branch)**: Warns about fetch failures but allows creation using the local branch as a fallback. This supports offline development or when no remote is configured.
|
|
366
|
+
**Network Behavior:**
|
|
377
367
|
|
|
378
|
-
|
|
368
|
+
- **New branches without `--from`**: Fetches defaultBranch from remote, falls back to local if fetch fails (offline support)
|
|
369
|
+
- **New branches with `--from`**: Requires successful remote fetch, exits on failure (ensures fresh code)
|
|
370
|
+
- **Local branches**: Used directly without network access
|
|
371
|
+
- **Remote-only branches**: Fetches and creates local tracking branch, uses cached remote ref if fetch fails
|
|
379
372
|
|
|
380
373
|
**Network Failure Handling:**
|
|
381
374
|
|
|
382
375
|
- 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.
|
|
383
|
-
-
|
|
376
|
+
- For local branches, no network is required.
|
|
377
|
+
- For remote-only branches or new branches without `--from`, fetch failures trigger a warning but allow creation using local/cached refs.
|
|
384
378
|
|
|
385
379
|
**Upstream Tracking:**
|
|
386
380
|
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.
|
|
@@ -1258,7 +1252,7 @@ gw list -v # Verbose output
|
|
|
1258
1252
|
|
|
1259
1253
|
#### remove (rm)
|
|
1260
1254
|
|
|
1261
|
-
Remove a worktree from the repository.
|
|
1255
|
+
Remove a worktree from the repository. By default, also deletes the local branch to prevent orphaned branches.
|
|
1262
1256
|
|
|
1263
1257
|
```bash
|
|
1264
1258
|
gw remove <worktree>
|
|
@@ -1266,7 +1260,16 @@ gw remove <worktree>
|
|
|
1266
1260
|
gw rm <worktree>
|
|
1267
1261
|
```
|
|
1268
1262
|
|
|
1269
|
-
**
|
|
1263
|
+
**Branch Cleanup:**
|
|
1264
|
+
|
|
1265
|
+
By default, `gw remove` deletes the local branch after removing the worktree:
|
|
1266
|
+
|
|
1267
|
+
- Uses safe delete (`git branch -d`) which warns if branch has unmerged commits
|
|
1268
|
+
- Use `--preserve-branch` to keep the local branch
|
|
1269
|
+
- Use `--force` to force delete unmerged branches
|
|
1270
|
+
- Protected branches (main, master, defaultBranch, gw_root) are never deleted
|
|
1271
|
+
|
|
1272
|
+
**Protected Worktrees:**
|
|
1270
1273
|
|
|
1271
1274
|
The following worktrees are protected and cannot be removed:
|
|
1272
1275
|
|
|
@@ -1277,9 +1280,10 @@ The following worktrees are protected and cannot be removed:
|
|
|
1277
1280
|
**Examples:**
|
|
1278
1281
|
|
|
1279
1282
|
```bash
|
|
1280
|
-
gw remove feat-branch
|
|
1281
|
-
gw remove
|
|
1282
|
-
gw
|
|
1283
|
+
gw remove feat-branch # Remove worktree AND delete local branch
|
|
1284
|
+
gw remove feat-branch --preserve-branch # Remove worktree but KEEP local branch
|
|
1285
|
+
gw remove --force feat-branch # Force remove worktree and force delete branch
|
|
1286
|
+
gw rm feat-branch # Using alias
|
|
1283
1287
|
```
|
|
1284
1288
|
|
|
1285
1289
|
#### move (mv)
|