@gw-tools/gw 0.20.4 → 0.20.7
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 +117 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ A command-line tool for managing git worktrees, built with Deno.
|
|
|
7
7
|
- [gw - Git Worktree Tools](#gw---git-worktree-tools)
|
|
8
8
|
- [Table of Contents](#table-of-contents)
|
|
9
9
|
- [Quick Start](#quick-start)
|
|
10
|
+
- [🎓 AI Skills (for Claude Code, Copilot, Cursor, etc.)](#-ai-skills-for-claude-code-copilot-cursor-etc)
|
|
10
11
|
- [Initial Setup: Secrets in the Default Branch](#initial-setup-secrets-in-the-default-branch)
|
|
11
12
|
- [First-Time Setup Flow](#first-time-setup-flow)
|
|
12
13
|
- [Why This Matters](#why-this-matters)
|
|
@@ -47,22 +48,23 @@ A command-line tool for managing git worktrees, built with Deno.
|
|
|
47
48
|
- [How It Works](#how-it-works-3)
|
|
48
49
|
- [init](#init)
|
|
49
50
|
- [Options](#options-3)
|
|
50
|
-
- [Examples](#examples
|
|
51
|
+
- [Clone Examples](#clone-examples)
|
|
52
|
+
- [Existing Repository Examples](#existing-repository-examples)
|
|
51
53
|
- [Hook Variables](#hook-variables)
|
|
52
54
|
- [Auto-Cleanup Configuration](#auto-cleanup-configuration)
|
|
53
55
|
- [When to Use](#when-to-use)
|
|
54
56
|
- [show-init](#show-init)
|
|
55
57
|
- [Options](#options-4)
|
|
56
|
-
- [Examples](#examples-
|
|
58
|
+
- [Examples](#examples-6)
|
|
57
59
|
- [Output Example](#output-example)
|
|
58
60
|
- [When to Use](#when-to-use-1)
|
|
59
61
|
- [sync](#sync)
|
|
60
62
|
- [Arguments](#arguments-3)
|
|
61
63
|
- [Options](#options-5)
|
|
62
|
-
- [Examples](#examples-
|
|
64
|
+
- [Examples](#examples-7)
|
|
63
65
|
- [clean](#clean)
|
|
64
66
|
- [Options](#options-6)
|
|
65
|
-
- [Examples](#examples-
|
|
67
|
+
- [Examples](#examples-8)
|
|
66
68
|
- [How It Works](#how-it-works-4)
|
|
67
69
|
- [Git Worktree Proxy Commands](#git-worktree-proxy-commands)
|
|
68
70
|
- [list (ls)](#list-ls)
|
|
@@ -95,21 +97,21 @@ A command-line tool for managing git worktrees, built with Deno.
|
|
|
95
97
|
|
|
96
98
|
```bash
|
|
97
99
|
# Install (Homebrew on macOS)
|
|
98
|
-
brew install mthines/gw-tools/gw
|
|
100
|
+
brew install mthines/gw-tools/gw
|
|
99
101
|
|
|
100
102
|
# Or install via npm
|
|
101
|
-
npm install -g @gw-tools/gw
|
|
103
|
+
npm install -g @gw-tools/gw
|
|
102
104
|
|
|
103
105
|
# Or install via Linux package manager
|
|
104
|
-
yay -S gw-tools
|
|
106
|
+
yay -S gw-tools
|
|
105
107
|
|
|
106
108
|
# Clone a repository with gw setup (interactive prompts for configuration)
|
|
107
109
|
gw init git@github.com:user/repo.git --interactive
|
|
108
110
|
# Automatically navigates to the new repository
|
|
109
111
|
|
|
110
112
|
# Create worktrees and start working
|
|
111
|
-
gw add feat
|
|
112
|
-
gw cd feat
|
|
113
|
+
gw add feat/new-feature
|
|
114
|
+
gw cd feat/new-feature
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
**Existing Repository Setup:**
|
|
@@ -119,13 +121,42 @@ gw cd feat-new-feature
|
|
|
119
121
|
gw init --auto-copy-files .env,secrets/ --post-add "pnpm install"
|
|
120
122
|
|
|
121
123
|
# Create worktrees - files are copied automatically, dependencies installed
|
|
122
|
-
gw add feat
|
|
123
|
-
gw cd feat
|
|
124
|
+
gw add feat/another-feature
|
|
125
|
+
gw cd feat/another-feature
|
|
124
126
|
|
|
125
127
|
# Checkout an existing branch (navigates if already checked out elsewhere)
|
|
126
128
|
gw checkout main
|
|
127
129
|
```
|
|
128
130
|
|
|
131
|
+
## 🎓 AI Skills (for Claude Code, Copilot, Cursor, etc.)
|
|
132
|
+
|
|
133
|
+
Enhance your AI agent with gw-tools knowledge using [skills.sh](https://skills.sh):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npx skills add https://github.com/mthines/gw-tools --skill @gw-git-worktree-workflows @gw-config-management @gw-autonomous-workflow # installs all skills
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Master Git worktrees and gw workflows
|
|
141
|
+
npx skills add https://github.com/mthines/gw-tools --skill @gw-git-worktree-workflows
|
|
142
|
+
|
|
143
|
+
# Configure gw for your project type (Next.js, monorepos, etc.)
|
|
144
|
+
npx skills add https://github.com/mthines/gw-tools --skill @gw-config-management
|
|
145
|
+
|
|
146
|
+
# Autonomous feature development workflow
|
|
147
|
+
npx skills add https://github.com/mthines/gw-tools --skill @gw-autonomous-workflow
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Once installed, your AI agent can:
|
|
151
|
+
|
|
152
|
+
- Execute complete feature development cycles autonomously
|
|
153
|
+
- Create worktrees for bug fixes and features automatically
|
|
154
|
+
- Configure gw for your specific project type
|
|
155
|
+
- Navigate between worktrees and manage files
|
|
156
|
+
- Create tested PRs from isolated worktrees
|
|
157
|
+
|
|
158
|
+
📖 **Skill documentation:** [skills/README.md](../../skills/README.md)
|
|
159
|
+
|
|
129
160
|
## Initial Setup: Secrets in the Default Branch
|
|
130
161
|
|
|
131
162
|
**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.
|
|
@@ -156,8 +187,8 @@ mkdir -p secrets/
|
|
|
156
187
|
|
|
157
188
|
# 3. Now create feature worktrees - files are copied automatically from main
|
|
158
189
|
cd ..
|
|
159
|
-
gw add feat
|
|
160
|
-
# .env and secrets/ are automatically copied from main to feat
|
|
190
|
+
gw add feat/new-feature
|
|
191
|
+
# .env and secrets/ are automatically copied from main to feat/new-feature
|
|
161
192
|
```
|
|
162
193
|
|
|
163
194
|
**Alternative: Non-Interactive Setup**
|
|
@@ -195,11 +226,13 @@ gw sync feat-existing-branch .env
|
|
|
195
226
|
|
|
196
227
|
## Features
|
|
197
228
|
|
|
229
|
+
- **Easy setup**: Clone and configure repositories in one command with `gw init <url> --interactive`
|
|
198
230
|
- **Quick navigation**: Navigate to worktrees instantly with smart partial matching (`gw cd feat` finds `feat-branch`)
|
|
199
231
|
- **Smart checkout**: `gw checkout` handles worktree-specific scenarios, navigating to branches checked out elsewhere instead of showing errors
|
|
232
|
+
- **Auto-copy files**: Configure once, automatically copy `.env`, secrets, and config files to every new worktree
|
|
233
|
+
- **Hooks support**: Run commands before/after worktree creation (install dependencies, validate setup, etc.)
|
|
200
234
|
- **Copy files between worktrees**: Easily copy secrets, environment files, and configurations from one worktree to another
|
|
201
235
|
- **Automatic shell integration**: Shell function installs automatically on npm install for seamless `gw cd` navigation
|
|
202
|
-
- **Multi-command architecture**: Extensible framework for adding new worktree management commands
|
|
203
236
|
- **Auto-configured per repository**: Each repository gets its own local config file, automatically created on first use
|
|
204
237
|
- **Dry-run mode**: Preview what would be copied without making changes
|
|
205
238
|
- **Standalone binary**: Compiles to a single executable with no runtime dependencies
|
|
@@ -485,7 +518,7 @@ gw cd <worktree>
|
|
|
485
518
|
# Navigate to a worktree by exact name
|
|
486
519
|
gw cd feat-branch
|
|
487
520
|
|
|
488
|
-
# Navigate using partial match (finds "feat
|
|
521
|
+
# Navigate using partial match (finds "feat/new-feature")
|
|
489
522
|
gw cd feat
|
|
490
523
|
|
|
491
524
|
# If multiple matches found, shows list with helpful error:
|
|
@@ -783,38 +816,52 @@ gw init [repository-url] [directory] [options]
|
|
|
783
816
|
|
|
784
817
|
#### Clone Examples
|
|
785
818
|
|
|
786
|
-
Clone a repository and automatically set up gw configuration
|
|
819
|
+
Clone a repository and automatically set it up with gw configuration. **This is the recommended way to start using gw with a new project.**
|
|
787
820
|
|
|
788
821
|
```bash
|
|
789
|
-
# Clone and
|
|
790
|
-
gw init git@github.com:user/repo.git
|
|
822
|
+
# Clone and configure interactively (RECOMMENDED - prompts for all options)
|
|
823
|
+
gw init git@github.com:user/repo.git --interactive
|
|
824
|
+
# Prompts for:
|
|
825
|
+
# - Auto-copy files (.env, secrets/, etc.)
|
|
826
|
+
# - Pre-add and post-add hooks (pnpm install, etc.)
|
|
827
|
+
# - Clean threshold
|
|
828
|
+
# - Update strategy
|
|
829
|
+
# Then automatically creates the main worktree and navigates to the repo
|
|
830
|
+
|
|
831
|
+
# Clone with configuration in one command (non-interactive)
|
|
832
|
+
gw init git@github.com:user/repo.git \
|
|
833
|
+
--auto-copy-files .env,secrets/ \
|
|
834
|
+
--post-add "pnpm install"
|
|
791
835
|
|
|
792
836
|
# Clone into specific directory
|
|
793
|
-
gw init git@github.com:user/repo.git my-project
|
|
837
|
+
gw init git@github.com:user/repo.git my-project --interactive
|
|
794
838
|
|
|
795
839
|
# Clone with HTTPS URL
|
|
796
|
-
gw init https://github.com/user/repo.git
|
|
797
|
-
|
|
798
|
-
# Clone and configure interactively
|
|
799
|
-
gw init git@github.com:user/repo.git --interactive
|
|
840
|
+
gw init https://github.com/user/repo.git --interactive
|
|
800
841
|
|
|
801
|
-
#
|
|
802
|
-
gw init git@github.com:user/repo.git
|
|
842
|
+
# Simple clone with defaults (no configuration yet)
|
|
843
|
+
gw init git@github.com:user/repo.git
|
|
803
844
|
```
|
|
804
845
|
|
|
805
|
-
|
|
846
|
+
**What happens when you clone with `gw init`:**
|
|
806
847
|
|
|
807
|
-
1.
|
|
808
|
-
2.
|
|
809
|
-
3. Auto-
|
|
810
|
-
4.
|
|
811
|
-
5.
|
|
812
|
-
6. Automatically
|
|
848
|
+
1. Clones the repository with `--no-checkout`
|
|
849
|
+
2. Creates a `gw_root` branch
|
|
850
|
+
3. Auto-detects the default branch from the remote
|
|
851
|
+
4. Creates gw configuration (`.gw/config.json`)
|
|
852
|
+
5. Creates the default branch worktree (e.g., `main`)
|
|
853
|
+
6. Automatically navigates to the repository directory (requires shell integration)
|
|
813
854
|
|
|
814
|
-
**
|
|
855
|
+
**Benefits:**
|
|
856
|
+
|
|
857
|
+
- No need to manually run `git clone --bare` or `git worktree add`
|
|
858
|
+
- Configuration is set up immediately
|
|
859
|
+
- Ready to use `gw add` right away
|
|
860
|
+
|
|
861
|
+
**Notes:**
|
|
815
862
|
|
|
816
863
|
- Cloned repositories use the `.git` suffix (e.g., `repo.git`) following bare repository conventions
|
|
817
|
-
- After cloning, you'
|
|
864
|
+
- After cloning, you're automatically in the repository root and can run `cd main` or `gw cd main`
|
|
818
865
|
- Shell integration must be installed (`gw install-shell`) for automatic navigation to work
|
|
819
866
|
|
|
820
867
|
#### Existing Repository Examples
|
|
@@ -1144,6 +1191,7 @@ gw rm <worktree>
|
|
|
1144
1191
|
**Protected Branches:**
|
|
1145
1192
|
|
|
1146
1193
|
The following worktrees are protected and cannot be removed:
|
|
1194
|
+
|
|
1147
1195
|
- Default branch (configured in `.gw/config.json`, typically `main`)
|
|
1148
1196
|
- `gw_root` (bare repository root branch)
|
|
1149
1197
|
- Bare repository worktree
|
|
@@ -1278,24 +1326,51 @@ The tool automatically detects which git repository you're working in and create
|
|
|
1278
1326
|
|
|
1279
1327
|
### Typical Workflow
|
|
1280
1328
|
|
|
1329
|
+
**Starting with a new repository:**
|
|
1330
|
+
|
|
1281
1331
|
```bash
|
|
1282
|
-
#
|
|
1283
|
-
gw init
|
|
1332
|
+
# Clone and set up with gw (one command!)
|
|
1333
|
+
gw init git@github.com:user/repo.git --interactive
|
|
1334
|
+
# Configure auto-copy files, hooks, etc. during the interactive prompts
|
|
1335
|
+
# Automatically navigates to the repo and creates main worktree
|
|
1284
1336
|
|
|
1285
|
-
#
|
|
1286
|
-
|
|
1287
|
-
|
|
1337
|
+
# Set up secrets in main worktree
|
|
1338
|
+
cd main
|
|
1339
|
+
cp .env.example .env
|
|
1340
|
+
# Edit .env with your secrets
|
|
1288
1341
|
|
|
1289
|
-
#
|
|
1290
|
-
|
|
1342
|
+
# Create feature worktrees - files copied automatically
|
|
1343
|
+
cd ..
|
|
1344
|
+
gw add feat/new-feature
|
|
1345
|
+
# Already in feat/new-feature worktree!
|
|
1291
1346
|
|
|
1292
1347
|
# Keep your feature branch updated with latest changes from main
|
|
1293
1348
|
gw update
|
|
1294
1349
|
|
|
1350
|
+
# Navigate between worktrees easily
|
|
1351
|
+
gw cd main
|
|
1352
|
+
gw cd feat/new-feature
|
|
1353
|
+
```
|
|
1354
|
+
|
|
1355
|
+
**Working with an existing repository:**
|
|
1356
|
+
|
|
1357
|
+
```bash
|
|
1358
|
+
# One-time setup: Configure auto-copy files and hooks
|
|
1359
|
+
gw init --auto-copy-files .env,components/agents/.env,components/ui/.vercel/ \
|
|
1360
|
+
--post-add "pnpm install"
|
|
1361
|
+
|
|
1362
|
+
# From within any worktree of your repository
|
|
1363
|
+
# Create a new worktree with auto-copy and hooks
|
|
1364
|
+
gw add feat/new-feature
|
|
1365
|
+
# Automatically: copies files, runs hooks, navigates to new worktree
|
|
1366
|
+
|
|
1295
1367
|
# Navigate to main worktree (if you need to work on it)
|
|
1296
1368
|
gw checkout main # or gw co main
|
|
1297
1369
|
|
|
1298
|
-
#
|
|
1370
|
+
# Keep your feature branch updated
|
|
1371
|
+
gw update
|
|
1372
|
+
|
|
1373
|
+
# Alternative: Create worktree and copy specific files (overrides config)
|
|
1299
1374
|
gw add feat-bugfix .env custom-config.json
|
|
1300
1375
|
|
|
1301
1376
|
# Alternative: Use the manual sync command
|