@gw-tools/gw 0.12.16 → 0.12.17
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 +51 -1
- 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`)
|
|
@@ -565,8 +614,9 @@ gw init --auto-clean --auto-copy-files .env --post-add "pnpm install"
|
|
|
565
614
|
```
|
|
566
615
|
|
|
567
616
|
**How it works:**
|
|
568
|
-
- Runs automatically on `gw add` and `gw list` commands
|
|
617
|
+
- Runs automatically on `gw add` and `gw list` commands (in the background, non-blocking)
|
|
569
618
|
- Only runs once per 24 hours (cooldown)
|
|
619
|
+
- **Never removes the `defaultBranch` worktree** - it's protected as the source for file syncing
|
|
570
620
|
- Removes worktrees older than `cleanThreshold` with:
|
|
571
621
|
- No uncommitted changes
|
|
572
622
|
- No staged files
|