@gw-tools/gw 0.12.16 → 0.12.18

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 +62 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -102,6 +102,55 @@ gw add feat-another-feature
102
102
  gw cd feat-another-feature
103
103
  ```
104
104
 
105
+ ## Initial Setup: Secrets in the Default Branch
106
+
107
+ **Important:** Before using `gw add` with auto-copy, ensure your secrets and environment files exist in your `defaultBranch` worktree (typically `main`). This worktree is the **source** from which files are copied to new worktrees.
108
+
109
+ ### First-Time Setup Flow
110
+
111
+ ```bash
112
+ # 1. Set up your bare repository structure
113
+ git clone --bare https://github.com/user/repo.git repo.git
114
+ cd repo.git
115
+
116
+ # 2. Create the main worktree (your defaultBranch)
117
+ git worktree add main main
118
+
119
+ # 3. Set up secrets in the main worktree FIRST
120
+ cd main
121
+ cp .env.example .env # Create your environment file
122
+ # Edit .env with your actual secrets, API keys, etc.
123
+ mkdir -p secrets/
124
+ # Add any other secret files your project needs
125
+
126
+ # 4. Initialize gw with auto-copy configuration
127
+ gw init --auto-copy-files .env,secrets/
128
+
129
+ # 5. Now create feature worktrees - files are copied automatically from main
130
+ cd ..
131
+ gw add feat-new-feature
132
+ # .env and secrets/ are automatically copied from main to feat-new-feature
133
+ ```
134
+
135
+ ### Why This Matters
136
+
137
+ - **`gw add`** copies files **from** your `defaultBranch` worktree **to** the new worktree
138
+ - **`gw sync`** also uses `defaultBranch` as the source (unless `--from` is specified)
139
+ - **Auto-clean** will **never** remove the `defaultBranch` worktree, ensuring your source files are always available
140
+ - If secrets don't exist in `defaultBranch`, they won't be copied to new worktrees
141
+
142
+ ### Keeping Secrets Updated
143
+
144
+ When you update secrets in your `defaultBranch` worktree, sync them to existing worktrees:
145
+
146
+ ```bash
147
+ # Sync all autoCopyFiles to an existing worktree
148
+ gw sync feat-existing-branch
149
+
150
+ # Or sync specific files
151
+ gw sync feat-existing-branch .env
152
+ ```
153
+
105
154
  ## Features
106
155
 
107
156
  - **Quick navigation**: Navigate to worktrees instantly with smart partial matching (`gw cd feat` finds `feat-branch`)
@@ -223,6 +272,9 @@ When `gw add` creates a new branch, it automatically configures the branch to tr
223
272
  **Git Ref Conflict Detection:**
224
273
  The command automatically detects and prevents Git ref naming conflicts. For example, you cannot have both a branch named `test` and `test/foo` because Git stores branches as files in `.git/refs/heads/`, and `test` cannot be both a file and a directory. If a conflict is detected, you'll receive a helpful error message with suggestions for resolving it.
225
274
 
275
+ **Existing Worktree Navigation:**
276
+ If you try to add a worktree that already exists, the command will prompt you to navigate to it instead. Press Enter (default: Yes) to navigate, or type 'n' to cancel. This requires shell integration to be installed (see [install-shell](#install-shell)).
277
+
226
278
  #### Arguments
227
279
 
228
280
  - `<worktree-name>`: Name or path for the new worktree
@@ -252,6 +304,14 @@ gw add feat/new-feature .env secrets/
252
304
 
253
305
  # Force create even if branch exists elsewhere
254
306
  gw add feat/bugfix -f
307
+
308
+ # If worktree already exists, prompts to navigate to it
309
+ gw add feat/existing-branch
310
+ # Output: Worktree feat/existing-branch already exists at:
311
+ # /path/to/repo/feat/existing-branch
312
+ #
313
+ # Navigate to it? [Y/n]:
314
+ # (Press Enter to navigate, or 'n' to cancel)
255
315
  ```
256
316
 
257
317
  #### Auto-Copy Configuration
@@ -565,8 +625,9 @@ gw init --auto-clean --auto-copy-files .env --post-add "pnpm install"
565
625
  ```
566
626
 
567
627
  **How it works:**
568
- - Runs automatically on `gw add` and `gw list` commands
628
+ - Runs automatically on `gw add` and `gw list` commands (in the background, non-blocking)
569
629
  - Only runs once per 24 hours (cooldown)
630
+ - **Never removes the `defaultBranch` worktree** - it's protected as the source for file syncing
570
631
  - Removes worktrees older than `cleanThreshold` with:
571
632
  - No uncommitted changes
572
633
  - No staged files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw-tools/gw",
3
- "version": "0.12.16",
3
+ "version": "0.12.18",
4
4
  "description": "A command-line tool for managing git worktrees - copy files between worktrees with ease",
5
5
  "keywords": [
6
6
  "git",