@shivanshshrivas/gwit 0.1.3 → 0.2.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 +91 -5
- package/dist/index.cjs +880 -61
- package/package.json +24 -4
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
# gwit
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# gwit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@shivanshshrivas/gwit)
|
|
4
|
+
[](https://www.npmjs.com/package/@shivanshshrivas/gwit)
|
|
5
|
+
[](https://github.com/shivanshshrivas/gwit/actions/workflows/ci.yml)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
9
|
+
Fully isolated git worktrees, in one command.
|
|
4
10
|
|
|
5
11
|
gwit wraps `git worktree` to turn a fresh checkout into a fully working environment - gitignored files copied, unique port assigned, per-worktree env vars injected, and setup scripts run automatically.
|
|
6
12
|
|
|
@@ -26,9 +32,16 @@ gwit -b fix/login-page # create a new branch from HEAD
|
|
|
26
32
|
|
|
27
33
|
# Day-to-day
|
|
28
34
|
gwit list # show all active worktrees
|
|
35
|
+
gwit status # see ahead/behind, dirty state, PR info
|
|
29
36
|
gwit sync feature/auth # re-copy files after .env changes
|
|
37
|
+
gwit sync --back feature/auth # three-way merge .gwitinclude files back to main
|
|
30
38
|
gwit open feature/auth # re-open editor for an existing worktree
|
|
39
|
+
|
|
40
|
+
# Merge and clean up
|
|
41
|
+
gwit merge feature/auth # merge branch back into main
|
|
31
42
|
gwit remove feature/auth # run cleanup hooks and remove worktree
|
|
43
|
+
gwit sweep # bulk-remove all merged worktrees
|
|
44
|
+
gwit rename old/name new/name # rename a worktree branch
|
|
32
45
|
```
|
|
33
46
|
|
|
34
47
|
## How it works
|
|
@@ -102,13 +115,26 @@ gwit remove feature/auth --force # skip uncommitted-changes check
|
|
|
102
115
|
|
|
103
116
|
### `gwit sync [branch]`
|
|
104
117
|
|
|
105
|
-
|
|
118
|
+
By default, re-copy `.gwitinclude` files from main into an existing worktree.
|
|
119
|
+
With `--back`, sync in the reverse direction using snapshot-aware three-way merge.
|
|
106
120
|
|
|
107
121
|
```sh
|
|
108
122
|
gwit sync feature/auth # sync a specific branch
|
|
109
123
|
gwit sync # auto-detect from current directory (when inside a worktree)
|
|
124
|
+
gwit sync --back feature/auth # three-way merge worktree -> main
|
|
125
|
+
gwit sync --back # auto-detect branch, then merge back
|
|
110
126
|
```
|
|
111
127
|
|
|
128
|
+
`--back` compares three versions of each snapshot-tracked file:
|
|
129
|
+
|
|
130
|
+
1. **base** - file content captured when the worktree was created
|
|
131
|
+
2. **main** - current file in the main worktree
|
|
132
|
+
3. **worktree** - current file in the linked worktree
|
|
133
|
+
|
|
134
|
+
If both sides changed different text regions, gwit applies a clean merge.
|
|
135
|
+
If both sides changed the same region, gwit writes git-style conflict markers
|
|
136
|
+
(`<<<<<<<`, `=======`, `>>>>>>>`). Binary conflicts are skipped with a warning.
|
|
137
|
+
|
|
112
138
|
### `gwit open <branch>`
|
|
113
139
|
|
|
114
140
|
Re-open the editor for an existing worktree. Useful when the editor window was closed.
|
|
@@ -118,6 +144,62 @@ gwit open feature/auth
|
|
|
118
144
|
gwit open feature/auth --editor cursor
|
|
119
145
|
```
|
|
120
146
|
|
|
147
|
+
### `gwit merge <branch>`
|
|
148
|
+
|
|
149
|
+
Merge a worktree branch back into the target branch. Combines git-tracked changes (via real git merge) with gitignored files (via reverse `.gwitinclude` sync) in a single command.
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
gwit merge feature/auth # standard merge into default branch
|
|
153
|
+
gwit merge feature/auth --into dev # merge into a specific branch
|
|
154
|
+
gwit merge feature/auth --squash # squash all commits into one
|
|
155
|
+
gwit merge feature/auth --rebase # rebase onto target, then fast-forward
|
|
156
|
+
gwit merge feature/auth --no-ff # force a merge commit
|
|
157
|
+
gwit merge feature/auth --cleanup # remove worktree after successful merge
|
|
158
|
+
gwit merge feature/auth --no-sync-back # skip reverse .gwitinclude copy
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
What it does, in order:
|
|
162
|
+
|
|
163
|
+
1. Validates the worktree exists in the registry
|
|
164
|
+
2. Resolves the target branch (default: repo's default branch)
|
|
165
|
+
3. Three-way syncs `.gwitinclude` files back to main (falls back to direct copy if no snapshot; unless `--no-sync-back`)
|
|
166
|
+
4. Checks out the target branch in the main worktree
|
|
167
|
+
5. Merges the feature branch using the chosen strategy
|
|
168
|
+
6. Optionally removes the worktree (`--cleanup`)
|
|
169
|
+
|
|
170
|
+
If the merge fails with conflicts, gwit exits with a helpful message so you can resolve manually.
|
|
171
|
+
|
|
172
|
+
### `gwit status`
|
|
173
|
+
|
|
174
|
+
Show detailed status of all active gwit worktrees.
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
gwit status # rich table output
|
|
178
|
+
gwit status --json # machine-readable JSON
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Displays per-worktree: branch, path, port, ahead/behind counts, dirty-file count, and PR info (if [`gh` CLI](https://cli.github.com) is installed).
|
|
182
|
+
|
|
183
|
+
### `gwit sweep`
|
|
184
|
+
|
|
185
|
+
Bulk-remove worktrees whose branches are fully merged into the default branch or whose GitHub PRs are merged/closed.
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
gwit sweep # interactive confirmation
|
|
189
|
+
gwit sweep --dry-run # show what would be removed
|
|
190
|
+
gwit sweep --force # skip confirmation
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Runs cleanup hooks for each removed worktree, just like `gwit remove`.
|
|
194
|
+
|
|
195
|
+
### `gwit rename <old-branch> <new-branch>`
|
|
196
|
+
|
|
197
|
+
Rename a worktree's git branch, move the directory (if the slug changes), and update the registry atomically.
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
gwit rename feature/auth feature/authentication
|
|
201
|
+
```
|
|
202
|
+
|
|
121
203
|
### `gwit config`
|
|
122
204
|
|
|
123
205
|
Show or update global configuration stored in `~/.gwitrc`.
|
|
@@ -145,15 +227,19 @@ gwit config set basePort 4000 # starting port for auto-assignment
|
|
|
145
227
|
|
|
146
228
|
### `.gwitinclude`
|
|
147
229
|
|
|
148
|
-
List of gitignored files and directories to copy into every new worktree. One entry per line, comments with `#` ignored.
|
|
230
|
+
List of gitignored files and directories to copy into every new worktree. One entry per line, comments with `#` ignored. Supports glob patterns via [minimatch](https://github.com/isaacs/minimatch).
|
|
149
231
|
|
|
150
232
|
```
|
|
151
233
|
# .gwitinclude - files to copy into each new worktree
|
|
152
234
|
.env
|
|
153
235
|
.env.local
|
|
154
236
|
certs/
|
|
237
|
+
*.pem
|
|
238
|
+
secrets/**
|
|
155
239
|
```
|
|
156
240
|
|
|
241
|
+
Glob patterns (`*`, `?`, `[...]`, `**`) are expanded against the set of gitignored files in the repo. Literal entries are copied directly.
|
|
242
|
+
|
|
157
243
|
Only gitignored files are eligible to copy. Tracked files are silently skipped - gwit is an allowlist for files that must be present but cannot be committed.
|
|
158
244
|
|
|
159
245
|
### `.gwitcommand`
|