gitgrip 0.19.0

Multi-repo workflow tool - manage multiple git repositories as one
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# Gripspace Reference

The workspace file (`gripspace.yml`) defines your multi-repository workspace configuration. The canonical location is `.gitgrip/spaces/main/gripspace.yml`.

Legacy locations (`.gitgrip/manifests/manifest.yaml` and `.gitgrip/manifests/manifest.yml`) are still read for backward compatibility.

## Quick Start

Minimal manifest:

```yaml
version: 1

repos:
  frontend:
    url: git@github.com:myorg/frontend.git
    path: ./frontend

  backend:
    url: git@github.com:myorg/backend.git
    path: ./backend
```

## Schema Version

```yaml
version: 1  # Required - manifest schema version
```

Currently only version `1` is supported.

## Manifest Self-Tracking

Track the manifest repository itself for inclusion in sync, branch, and push operations:

```yaml
manifest:
  url: git@github.com:myorg/workspace-manifest.git
  default_branch: main

  # Optional: files to copy from manifest to workspace root
  copyfile:
    - src: envsetup.sh
      dest: envsetup.sh

  # Optional: symlinks from workspace to manifest files
  linkfile:
    - src: CLAUDE.md
      dest: CLAUDE.md
```

When `manifest` is defined:
- `gr sync` syncs the manifest repo first
- `gr branch` creates branches in the manifest repo
- `gr push` pushes the manifest repo
- `gr diff` shows manifest changes

## Gripspace Includes

Compose workspaces by inheriting configuration from shared gripspace repositories:

```yaml
gripspaces:
  - url: git@github.com:org/base-workspace.git
  - url: git@github.com:org/frontend-tools.git
    rev: v2.0.0  # Pin to branch, tag, or commit (default: remote HEAD)
```

Gripspace repos are cloned into `.gitgrip/spaces/<name>/` and their `gripspace.yml` manifests are merged into the local workspace during `gr sync` and `gr init`.

### What Gets Merged

| Section | Merge Strategy |
|---------|---------------|
| `repos` | Gripspace repos added first, local repos override by key |
| `scripts` | Gripspace scripts added first, local scripts override by key |
| `env` | Gripspace env added first, local env overrides by key |
| `hooks` | Gripspace hooks run first (deepest first), then local hooks |
| `copyfile` | Gripspace entries added, local entries override by dest |
| `linkfile` | Gripspace entries added, local entries override by dest |

**Local values always win on conflict.**

### Recursive Includes

Gripspaces can include other gripspaces (max depth 5). Resolution is depth-first with DAG-aware cycle detection — the same gripspace referenced from multiple parents is only resolved once.

### Composefiles

Generate files by concatenating parts from gripspaces and/or the local manifest:

```yaml
manifest:
  url: git@github.com:org/workspace.git
  composefile:
    - dest: CLAUDE.md
      separator: "\n\n"  # Optional (default: "\n\n")
      parts:
        - gripspace: base-workspace  # Read from .gitgrip/spaces/base-workspace/
          src: CODI.md
        - src: LOCAL_DOCS.md         # Read from local manifest content dir
```

Composefiles are processed on every `gr sync` and `gr link --apply`.

### URL Normalization

SSH and HTTPS URLs to the same repository are recognized as equivalent. If a gripspace directory already exists with a matching remote (even via a different protocol), it is reused rather than creating a duplicate:

```
git@github.com:org/repo.git  ↔  https://github.com/org/repo.git
```

## Repository Definitions

Each repository is defined under `repos`:

```yaml
repos:
  # Key is the repository name used in gr commands
  frontend:
    # Git URL - SSH or HTTPS (required)
    url: git@github.com:myorg/frontend.git

    # Local path relative to workspace root (required)
    path: ./frontend

    # Default branch (optional, defaults to "main")
    default_branch: main

    # Groups for selective operations (optional)
    groups:
      - core
      - web

    # Mark as read-only reference repo (optional, defaults to false)
    reference: false

    # Platform override (optional, auto-detected from URL)
    platform:
      type: github
      base_url: https://github.mycompany.com  # For Enterprise

    # Files to copy after clone/sync (optional)
    copyfile:
      - src: .env.example
        dest: .env.local

    # Symlinks to create in workspace (optional)
    linkfile:
      - src: dist/cli
        dest: .bin/tool
```

### Required Fields

| Field | Type | Description |
|-------|------|-------------|
| `url` | string | Git clone URL (SSH or HTTPS) |
| `path` | string | Local path relative to workspace root |

### Optional Fields

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `default_branch` | string | `main` | Branch to use for sync operations |
| `groups` | array | `[]` | Group names for filtering |
| `reference` | boolean | `false` | Read-only reference repository |
| `platform` | object | auto | Platform configuration |
| `copyfile` | array | - | Files to copy to workspace |
| `linkfile` | array | - | Symlinks to create |

## Groups

Groups allow selective operations on subsets of repositories:

```yaml
repos:
  frontend:
    url: git@github.com:myorg/frontend.git
    path: ./frontend
    groups:
      - core
      - web

  backend:
    url: git@github.com:myorg/backend.git
    path: ./backend
    groups:
      - core
      - api

  docs:
    url: git@github.com:myorg/docs.git
    path: ./docs
    groups:
      - docs
```

Use groups with commands:

```bash
gr sync --group core              # Sync only core repos
gr status --group web,api         # Status of web and api repos
gr branch feat/x --group core     # Branch only in core repos
```

Manage groups:

```bash
gr group list                     # List all groups
gr group add core shared-lib      # Add shared-lib to core group
gr group remove docs frontend     # Remove frontend from docs group
```

## Reference Repositories

Mark repositories as read-only references:

```yaml
repos:
  opencode:
    url: https://github.com/anthropics/opencode.git
    path: ./ref/opencode
    reference: true
```

Reference repos:
- Are synced with `gr sync`
- Are excluded from `gr branch`, `gr checkout`, `gr commit`, `gr push`
- Are excluded from `gr pr create/status/merge`
- Show `[ref]` indicator in `gr status`

Use for external dependencies, documentation repos, or code you don't modify.

## File Linking

### copyfile

Copy files from repository to workspace root after sync:

```yaml
repos:
  config:
    url: git@github.com:myorg/config.git
    path: ./config
    copyfile:
      - src: eslint.config.js
        dest: eslint.config.js
      - src: prettier.config.js
        dest: prettier.config.js
```

Files are copied (not linked) - changes to the copy don't affect the source.

### linkfile

Create symlinks from workspace to repository files:

```yaml
repos:
  tooling:
    url: git@github.com:myorg/tooling.git
    path: ./tooling
    linkfile:
      - src: bin/deploy
        dest: .bin/deploy
      - src: scripts/setup.sh
        dest: setup.sh
```

Symlinks point to the source - changes affect both locations.

### Link Commands

```bash
gr link                  # Create/update all links
gr link --status         # Show link status
gr link --clean          # Remove orphaned links
gr link --force          # Overwrite existing files
gr link --dry-run        # Preview changes
```

## Platform Configuration

gitgrip auto-detects platforms from URLs. Override for self-hosted instances:

```yaml
repos:
  internal:
    url: git@github.mycompany.com:team/repo.git
    path: ./internal
    platform:
      type: github
      base_url: https://github.mycompany.com
```

### Supported Platforms

| Type | Description |
|------|-------------|
| `github` | GitHub.com or GitHub Enterprise |
| `gitlab` | GitLab.com or self-hosted GitLab |
| `azure-devops` | Azure DevOps or Azure DevOps Server |
| `bitbucket` | Bitbucket Cloud or Bitbucket Server |

## Workspace Configuration

Global workspace settings:

```yaml
workspace:
  # Environment variables
  env:
    NODE_ENV: development
    WORKSPACE_NAME: myproject

  # Named scripts
  scripts:
    build:
      description: Build all packages
      command: npm run build

    test:
      description: Run all tests
      steps:
        - name: Lint
          command: npm run lint
        - name: Unit tests
          command: npm test

  # Lifecycle hooks
  hooks:
    post-sync:
      - command: npm install
        cwd: ./frontend
      - command: cargo build
        cwd: ./backend

    post-checkout:
      - command: ./scripts/setup.sh

  # CI/CD pipelines
  ci:
    pipelines:
      test:
        description: Run test suite
        steps:
          - name: Install
            command: npm ci
          - name: Test
            command: npm test
```

### Environment Variables

```yaml
workspace:
  env:
    NODE_ENV: development
    API_URL: http://localhost:3000
```

Access via `gr env` or in scripts.

### Scripts

```yaml
workspace:
  scripts:
    build:
      description: Build all packages
      command: pnpm -r build

    deploy:
      description: Deploy to production
      steps:
        - name: Build
          command: pnpm build
        - name: Push
          command: ./scripts/deploy.sh
          env:
            DEPLOY_ENV: production
```

Run with `gr run <name>`:

```bash
gr run --list            # List available scripts
gr run build             # Run build script
gr run build -- --watch  # Pass arguments
```

### Hooks

```yaml
workspace:
  hooks:
    post-sync:
      - command: npm install
        cwd: ./frontend

    post-checkout:
      - command: ./scripts/setup-env.sh
```

Hooks run automatically after their trigger event.

### CI/CD Pipelines

```yaml
workspace:
  ci:
    pipelines:
      test:
        description: Run test suite
        steps:
          - name: Install dependencies
            command: npm ci
          - name: Run tests
            command: npm test
            continue_on_error: false
          - name: Upload coverage
            command: npm run coverage:upload
            env:
              COVERAGE_TOKEN: ${COVERAGE_TOKEN}
```

Run with `gr ci`:

```bash
gr ci list               # List pipelines
gr ci run test           # Run test pipeline
gr ci status             # Show last run status
```

## Settings

Global tool behavior:

```yaml
settings:
  # PR title prefix
  pr_prefix: "[cross-repo]"

  # How to merge linked PRs
  merge_strategy: all-or-nothing
```

### Merge Strategies

| Strategy | Description |
|----------|-------------|
| `all-or-nothing` | All PRs must merge together or none do |
| `independent` | Each PR can be merged separately |

## Path Security

Paths must be relative and within the workspace:

- Paths cannot start with `..` or `/`
- Paths cannot contain `/../`
- Paths are validated to prevent directory traversal

```yaml
# Valid paths
path: ./frontend
path: apps/backend
path: packages/shared

# Invalid paths (rejected)
path: ../outside
path: /absolute/path
path: ./some/../../../escape
```

## Complete Example

```yaml
version: 1

manifest:
  url: git@github.com:myorg/workspace.git
  default_branch: main
  linkfile:
    - src: CLAUDE.md
      dest: CLAUDE.md

repos:
  frontend:
    url: git@github.com:myorg/frontend.git
    path: ./frontend
    default_branch: main
    groups:
      - core
      - web
    copyfile:
      - src: .env.example
        dest: .env.local

  backend:
    url: git@github.com:myorg/backend.git
    path: ./backend
    groups:
      - core
      - api

  shared:
    url: git@github.com:myorg/shared.git
    path: ./packages/shared
    groups:
      - core

  docs:
    url: git@github.com:myorg/docs.git
    path: ./docs
    reference: true

workspace:
  env:
    NODE_ENV: development

  scripts:
    build:
      description: Build all packages
      command: pnpm -r build

    test:
      description: Run all tests
      command: pnpm -r test

  hooks:
    post-sync:
      - command: pnpm install

settings:
  pr_prefix: "[multi-repo]"
  merge_strategy: all-or-nothing
```

## CLI Commands

View schema from CLI:

```bash
gr manifest schema              # YAML format
gr manifest schema --format json     # JSON format
gr manifest schema --format markdown # Markdown table
```

Import from git-repo XML:

```bash
gr manifest import              # Import default.xml
gr manifest sync                # Re-sync after repo changes
```