@gw-tools/gw 0.20.13 → 0.20.14
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 +27 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -366,30 +366,27 @@ If `autoCopyFiles` is configured, those files are automatically copied when crea
|
|
|
366
366
|
**Branch Creation Behavior:**
|
|
367
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.
|
|
368
368
|
|
|
369
|
-
**
|
|
369
|
+
**Branch Handling:**
|
|
370
|
+
`gw checkout` intelligently handles different branch scenarios:
|
|
370
371
|
|
|
371
|
-
|
|
372
|
+
1. **Local branches**: If the branch already exists locally, it's used directly. No network access required.
|
|
372
373
|
|
|
373
|
-
|
|
374
|
-
- Fetches the latest version of the source branch from the remote (e.g., `origin/main`)
|
|
375
|
-
- Creates your new branch from the fresh remote ref (e.g., `origin/main`)
|
|
376
|
-
- Sets up tracking to `origin/feat/new-feature` for easy pushing
|
|
374
|
+
2. **Remote-only branches**: If the branch exists only on remote (e.g., `origin/feat/something`), `gw checkout` fetches it and creates a proper local tracking branch. This ensures `git push` and `git pull` work correctly.
|
|
377
375
|
|
|
378
|
-
|
|
379
|
-
- Merge conflicts from missing recent changes
|
|
380
|
-
- Building features on old code
|
|
381
|
-
- Divergent histories that are hard to reconcile
|
|
376
|
+
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.
|
|
382
377
|
|
|
383
|
-
|
|
384
|
-
- **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.
|
|
385
|
-
- **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.
|
|
378
|
+
**Network Behavior:**
|
|
386
379
|
|
|
387
|
-
|
|
380
|
+
- **New branches without `--from`**: Fetches defaultBranch from remote, falls back to local if fetch fails (offline support)
|
|
381
|
+
- **New branches with `--from`**: Requires successful remote fetch, exits on failure (ensures fresh code)
|
|
382
|
+
- **Local branches**: Used directly without network access
|
|
383
|
+
- **Remote-only branches**: Fetches and creates local tracking branch, uses cached remote ref if fetch fails
|
|
388
384
|
|
|
389
385
|
**Network Failure Handling:**
|
|
390
386
|
|
|
391
387
|
- 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.
|
|
392
|
-
-
|
|
388
|
+
- For local branches, no network is required.
|
|
389
|
+
- For remote-only branches or new branches without `--from`, fetch failures trigger a warning but allow creation using local/cached refs.
|
|
393
390
|
|
|
394
391
|
**Upstream Tracking:**
|
|
395
392
|
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.
|
|
@@ -1209,7 +1206,7 @@ gw list -v # Verbose output
|
|
|
1209
1206
|
|
|
1210
1207
|
#### remove (rm)
|
|
1211
1208
|
|
|
1212
|
-
Remove a worktree from the repository.
|
|
1209
|
+
Remove a worktree from the repository. By default, also deletes the local branch to prevent orphaned branches.
|
|
1213
1210
|
|
|
1214
1211
|
```bash
|
|
1215
1212
|
gw remove <worktree>
|
|
@@ -1217,7 +1214,16 @@ gw remove <worktree>
|
|
|
1217
1214
|
gw rm <worktree>
|
|
1218
1215
|
```
|
|
1219
1216
|
|
|
1220
|
-
**
|
|
1217
|
+
**Branch Cleanup:**
|
|
1218
|
+
|
|
1219
|
+
By default, `gw remove` deletes the local branch after removing the worktree:
|
|
1220
|
+
|
|
1221
|
+
- Uses safe delete (`git branch -d`) which warns if branch has unmerged commits
|
|
1222
|
+
- Use `--preserve-branch` to keep the local branch
|
|
1223
|
+
- Use `--force` to force delete unmerged branches
|
|
1224
|
+
- Protected branches (main, master, defaultBranch, gw_root) are never deleted
|
|
1225
|
+
|
|
1226
|
+
**Protected Worktrees:**
|
|
1221
1227
|
|
|
1222
1228
|
The following worktrees are protected and cannot be removed:
|
|
1223
1229
|
|
|
@@ -1228,9 +1234,10 @@ The following worktrees are protected and cannot be removed:
|
|
|
1228
1234
|
**Examples:**
|
|
1229
1235
|
|
|
1230
1236
|
```bash
|
|
1231
|
-
gw remove feat-branch
|
|
1232
|
-
gw remove
|
|
1233
|
-
gw
|
|
1237
|
+
gw remove feat-branch # Remove worktree AND delete local branch
|
|
1238
|
+
gw remove feat-branch --preserve-branch # Remove worktree but KEEP local branch
|
|
1239
|
+
gw remove --force feat-branch # Force remove worktree and force delete branch
|
|
1240
|
+
gw rm feat-branch # Using alias
|
|
1234
1241
|
```
|
|
1235
1242
|
|
|
1236
1243
|
#### move (mv)
|