type-git 0.0.3 → 0.1.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.
@@ -1,2 +1,4233 @@
1
- import '../../adapters-w9tZ_Qbd.js';
2
- export { N as NodeExecAdapter, f as NodeFsAdapter, e as TypeGit, T as TypeGitOptions, d as createNodeAdapters } from '../../index-D9acU30I.js';
1
+ import { G as GitErrorCategory, e as ExecOpts, f as RawResult, L as LfsMode, g as GitProgress, h as GitOpenOptions, R as RuntimeAdapters, i as ExecutionContext, j as GitError, E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle } from '../../adapters-DehG3CsV.js';
2
+
3
+ /**
4
+ * stdout parsing utilities for Git output
5
+ *
6
+ * This module provides:
7
+ * - parseLines: Parse newline-separated output
8
+ * - parseRecords: Parse delimited records (NUL-terminated or custom)
9
+ * - parseJson: Parse JSON output
10
+ * - parseKeyValue: Parse key-value pairs
11
+ */
12
+ /**
13
+ * Parse newline-separated output into lines
14
+ *
15
+ * @param stdout - Raw stdout string
16
+ * @param options - Parse options
17
+ * @returns Array of non-empty lines
18
+ */
19
+ declare function parseLines(stdout: string, options?: {
20
+ /** Keep empty lines (default: false) */
21
+ keepEmpty?: boolean;
22
+ /** Trim each line (default: true) */
23
+ trim?: boolean;
24
+ }): string[];
25
+ /**
26
+ * Parse delimited records (e.g., NUL-terminated for --format with %x00)
27
+ *
28
+ * @param stdout - Raw stdout string
29
+ * @param delimiter - Record delimiter (default: '\0')
30
+ * @returns Array of records
31
+ */
32
+ declare function parseRecords(stdout: string, delimiter?: string): string[];
33
+ /**
34
+ * Parse JSON output from git commands
35
+ *
36
+ * @param stdout - Raw stdout string (single JSON object or NDJSON)
37
+ * @param options - Parse options
38
+ * @returns Parsed JSON value(s)
39
+ */
40
+ declare function parseJson<T = unknown>(stdout: string, options?: {
41
+ /** Parse as newline-delimited JSON (NDJSON) */
42
+ ndjson?: boolean;
43
+ }): T | T[];
44
+ /**
45
+ * Parse key-value pairs from git output
46
+ *
47
+ * Used for parsing config output, show --format output, etc.
48
+ *
49
+ * @param stdout - Raw stdout string
50
+ * @param options - Parse options
51
+ * @returns Map of key-value pairs
52
+ */
53
+ declare function parseKeyValue(stdout: string, options?: {
54
+ /** Key-value separator (default: '=') */
55
+ separator?: string;
56
+ /** Record delimiter (default: '\n') */
57
+ delimiter?: string;
58
+ }): Map<string, string>;
59
+ /**
60
+ * Parse porcelain v2 status output
61
+ *
62
+ * @param stdout - Raw stdout from `git status --porcelain=v2`
63
+ * @returns Parsed status entries
64
+ */
65
+ type PorcelainV2Entry = {
66
+ type: 'changed';
67
+ xy: string;
68
+ sub: string;
69
+ mH: string;
70
+ mI: string;
71
+ mW: string;
72
+ hH: string;
73
+ hI: string;
74
+ path: string;
75
+ origPath?: string;
76
+ } | {
77
+ type: 'untracked';
78
+ path: string;
79
+ } | {
80
+ type: 'ignored';
81
+ path: string;
82
+ } | {
83
+ type: 'unmerged';
84
+ xy: string;
85
+ sub: string;
86
+ m1: string;
87
+ m2: string;
88
+ m3: string;
89
+ mW: string;
90
+ h1: string;
91
+ h2: string;
92
+ h3: string;
93
+ path: string;
94
+ };
95
+ declare function parsePorcelainV2(stdout: string): PorcelainV2Entry[];
96
+ /**
97
+ * Parse git progress output from stderr
98
+ *
99
+ * Parses lines like:
100
+ * - "Counting objects: 100% (10/10), done."
101
+ * - "Compressing objects: 50% (4/8)"
102
+ * - "Receiving objects: 10% (1/10)"
103
+ *
104
+ * @param line - Single line from stderr
105
+ * @returns Parsed progress or null if not a progress line
106
+ */
107
+ type GitProgressInfo = {
108
+ phase: string;
109
+ current: number;
110
+ total: number | null;
111
+ percent: number | null;
112
+ done: boolean;
113
+ };
114
+ declare function parseGitProgress(line: string): GitProgressInfo | null;
115
+ /**
116
+ * Parse LFS progress file line
117
+ *
118
+ * Format: <direction> <oid> <bytes_so_far>/<bytes_total> <bytes_transferred>
119
+ *
120
+ * @param line - Single line from GIT_LFS_PROGRESS file
121
+ * @returns Parsed LFS progress or null if invalid
122
+ */
123
+ type LfsProgressInfo = {
124
+ direction: 'download' | 'upload' | 'checkout';
125
+ oid: string;
126
+ bytesSoFar: number;
127
+ bytesTotal: number;
128
+ bytesTransferred: number;
129
+ };
130
+ declare function parseLfsProgress(line: string): LfsProgressInfo | null;
131
+ /**
132
+ * Parse git ls-remote output
133
+ *
134
+ * Format: <hash>\t<refname>
135
+ *
136
+ * @param stdout - Raw stdout from `git ls-remote`
137
+ * @returns Parsed refs
138
+ */
139
+ type LsRemoteRef = {
140
+ hash: string;
141
+ name: string;
142
+ };
143
+ declare function parseLsRemote(stdout: string): LsRemoteRef[];
144
+ /**
145
+ * Object type in a tree
146
+ */
147
+ type LsTreeObjectType$1 = 'blob' | 'tree' | 'commit';
148
+ /**
149
+ * Entry from git ls-tree output
150
+ */
151
+ type ParsedLsTreeEntry = {
152
+ /** File mode (e.g., '100644' for regular file, '040000' for directory) */
153
+ mode: string;
154
+ /** Object type: blob (file), tree (directory), or commit (submodule) */
155
+ type: LsTreeObjectType$1;
156
+ /** Object hash (SHA-1 or SHA-256) */
157
+ hash: string;
158
+ /** File path relative to repository root */
159
+ path: string;
160
+ /** Object size in bytes (only for blobs when using --long option) */
161
+ size?: number;
162
+ };
163
+ /**
164
+ * Parse git ls-tree output
165
+ *
166
+ * Supports multiple output formats:
167
+ * - Default: <mode> <type> <hash>\t<path>
168
+ * - With --long: <mode> <type> <hash> <size>\t<path>
169
+ * - With --name-only: <path>
170
+ * - With --object-only: <hash>
171
+ *
172
+ * @param stdout - Raw stdout from `git ls-tree`
173
+ * @param opts - Parser options to handle different output modes
174
+ * @returns Parsed tree entries
175
+ */
176
+ declare function parseLsTree(stdout: string, opts?: {
177
+ nameOnly?: boolean;
178
+ objectOnly?: boolean;
179
+ long?: boolean;
180
+ }): ParsedLsTreeEntry[];
181
+ /**
182
+ * Commit information from git log
183
+ */
184
+ type ParsedCommit = {
185
+ hash: string;
186
+ abbrevHash: string;
187
+ parents: string[];
188
+ authorName: string;
189
+ authorEmail: string;
190
+ authorTimestamp: number;
191
+ committerName: string;
192
+ committerEmail: string;
193
+ committerTimestamp: number;
194
+ subject: string;
195
+ body: string;
196
+ };
197
+ /**
198
+ * The format string used for git log parsing
199
+ *
200
+ * Uses %x00 (NUL) as field separator and %x01 as record separator
201
+ */
202
+ declare const GIT_LOG_FORMAT = "%H%x00%h%x00%P%x00%an%x00%ae%x00%at%x00%cn%x00%ce%x00%ct%x00%s%x00%b%x01";
203
+ /**
204
+ * Parse git log output with our custom format
205
+ *
206
+ * @param stdout - Raw stdout from `git log --format=<GIT_LOG_FORMAT>`
207
+ * @returns Parsed commits
208
+ */
209
+ declare function parseGitLog(stdout: string): ParsedCommit[];
210
+ /**
211
+ * Worktree information from git worktree list --porcelain
212
+ */
213
+ type ParsedWorktree = {
214
+ path: string;
215
+ head: string;
216
+ branch?: string;
217
+ locked: boolean;
218
+ prunable: boolean;
219
+ };
220
+ /**
221
+ * Parse git worktree list --porcelain output
222
+ *
223
+ * Format:
224
+ * worktree /path/to/worktree
225
+ * HEAD <sha>
226
+ * branch refs/heads/main
227
+ * [locked [reason]]
228
+ * [prunable]
229
+ *
230
+ * @param stdout - Raw stdout from `git worktree list --porcelain`
231
+ * @returns Parsed worktrees
232
+ */
233
+ declare function parseWorktreeList(stdout: string): ParsedWorktree[];
234
+
235
+ /**
236
+ * Detect error category from stderr content (§13.3)
237
+ *
238
+ * @param stderr - stderr content from git command
239
+ * @returns Detected error category
240
+ */
241
+ declare function detectErrorCategory(stderr: string): GitErrorCategory;
242
+
243
+ /**
244
+ * Repository interfaces - operations that require a repository context
245
+ */
246
+
247
+ /**
248
+ * Base repository interface
249
+ */
250
+ interface RepoBase {
251
+ /**
252
+ * Execute a raw git command in this repository context
253
+ *
254
+ * Wraps: `git <argv...>`
255
+ */
256
+ raw(argv: string[], opts?: ExecOpts): Promise<RawResult>;
257
+ /**
258
+ * Check if this repository is a worktree repository (has working directory)
259
+ *
260
+ * Wraps: `git rev-parse --is-inside-work-tree`
261
+ *
262
+ * This is a runtime check that queries git to determine the repository type.
263
+ * Note: TypeScript cannot automatically narrow the type based on this check
264
+ * since it returns `Promise<boolean>`. Use type assertions after checking.
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const repo = await git.openRaw('/path/to/repo');
269
+ * if (await repo.isWorktree()) {
270
+ * // Use type assertion to access WorktreeRepo methods
271
+ * const status = await (repo as WorktreeRepo).status();
272
+ * }
273
+ * ```
274
+ */
275
+ isWorktree(): Promise<boolean>;
276
+ /**
277
+ * Check if this repository is a bare repository (no working directory)
278
+ *
279
+ * Wraps: `git rev-parse --is-bare-repository`
280
+ *
281
+ * This is a runtime check that queries git to determine the repository type.
282
+ * Note: TypeScript cannot automatically narrow the type based on this check
283
+ * since it returns `Promise<boolean>`. Use type assertions after checking.
284
+ *
285
+ * @example
286
+ * ```typescript
287
+ * const repo = await git.openRaw('/path/to/repo');
288
+ * if (await repo.isBare()) {
289
+ * // Use type assertion to access BareRepo methods
290
+ * await (repo as BareRepo).fetch({ remote: 'origin' });
291
+ * }
292
+ * ```
293
+ */
294
+ isBare(): Promise<boolean>;
295
+ /**
296
+ * List references in a remote repository
297
+ *
298
+ * Wraps: `git ls-remote <remote> [refs...]`
299
+ *
300
+ * Unlike the global `git.lsRemote(url)`, this method operates in the context
301
+ * of a repository and accepts a remote name (e.g., 'origin') instead of a URL.
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * // List all refs from origin
306
+ * const result = await repo.lsRemote('origin');
307
+ *
308
+ * // List specific branch
309
+ * const result = await repo.lsRemote('origin', { refs: ['main'] });
310
+ *
311
+ * // List only tags
312
+ * const result = await repo.lsRemote('origin', { tags: true });
313
+ * ```
314
+ */
315
+ lsRemote(remote: string, opts?: RepoLsRemoteOpts & ExecOpts): Promise<RepoLsRemoteResult>;
316
+ /**
317
+ * List contents of a tree object
318
+ *
319
+ * Wraps: `git ls-tree <tree-ish> [<path>...]`
320
+ *
321
+ * Lists the contents of a given tree object (commit, tag, or tree hash).
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * // List all files in HEAD
326
+ * const entries = await repo.lsTree('HEAD');
327
+ *
328
+ * // List files recursively with names only
329
+ * const names = await repo.lsTree('HEAD', { recursive: true, nameOnly: true });
330
+ *
331
+ * // List files in a specific directory
332
+ * const entries = await repo.lsTree('main', { paths: ['src/'] });
333
+ *
334
+ * // Get file sizes
335
+ * const entries = await repo.lsTree('HEAD', { long: true });
336
+ * ```
337
+ */
338
+ lsTree(treeish: string, opts?: LsTreeOpts & ExecOpts): Promise<LsTreeEntry[]>;
339
+ }
340
+ /**
341
+ * Options for repository-scoped git ls-remote
342
+ */
343
+ type RepoLsRemoteOpts = {
344
+ /** Limit to refs/heads (branches) */
345
+ heads?: boolean;
346
+ /** Limit to refs/tags */
347
+ tags?: boolean;
348
+ /** Show only actual refs (not peeled tags) */
349
+ refsOnly?: boolean;
350
+ /** Show remote URL instead of listing refs */
351
+ getUrl?: boolean;
352
+ /** Sort refs by the given key (e.g., 'version:refname') */
353
+ sort?: string;
354
+ /** Show symbolic refs in addition to object refs */
355
+ symref?: boolean;
356
+ /** Specific refs to query (branch names, tag names, or full ref paths) */
357
+ refs?: string[];
358
+ };
359
+ /**
360
+ * Result from repository-scoped git ls-remote
361
+ */
362
+ type RepoLsRemoteResult = {
363
+ refs: LsRemoteRef[];
364
+ };
365
+ /**
366
+ * Object type in a tree
367
+ */
368
+ type LsTreeObjectType = 'blob' | 'tree' | 'commit';
369
+ /**
370
+ * Entry from git ls-tree output
371
+ */
372
+ type LsTreeEntry = {
373
+ /** File mode (e.g., '100644' for regular file, '040000' for directory) */
374
+ mode: string;
375
+ /** Object type: blob (file), tree (directory), or commit (submodule) */
376
+ type: LsTreeObjectType;
377
+ /** Object hash (SHA-1 or SHA-256) */
378
+ hash: string;
379
+ /** File path relative to repository root */
380
+ path: string;
381
+ /** Object size in bytes (only for blobs when using --long option) */
382
+ size?: number;
383
+ };
384
+ /**
385
+ * Options for git ls-tree
386
+ */
387
+ type LsTreeOpts = {
388
+ /** Recurse into sub-trees (-r) */
389
+ recursive?: boolean;
390
+ /** Show only the named tree entry itself, not its children (-d) */
391
+ treeOnly?: boolean;
392
+ /** Show tree entries even when recursing (-t) */
393
+ showTrees?: boolean;
394
+ /** Show object size of blob entries (--long / -l) */
395
+ long?: boolean;
396
+ /** List only filenames (--name-only) */
397
+ nameOnly?: boolean;
398
+ /** List only object names/hashes (--object-only) */
399
+ objectOnly?: boolean;
400
+ /** Show full path names (--full-name) */
401
+ fullName?: boolean;
402
+ /** Do not limit listing to current working directory (--full-tree) */
403
+ fullTree?: boolean;
404
+ /** Abbreviate object names to at least n hexdigits (--abbrev) */
405
+ abbrev?: number | boolean;
406
+ /** Paths to filter (optional patterns to match) */
407
+ paths?: string[];
408
+ };
409
+ /**
410
+ * Status file entry
411
+ */
412
+ type StatusEntry = {
413
+ path: string;
414
+ index: string;
415
+ workdir: string;
416
+ originalPath?: string;
417
+ };
418
+ /**
419
+ * Result from git status --porcelain
420
+ */
421
+ type StatusPorcelain = {
422
+ entries: StatusEntry[];
423
+ branch?: string;
424
+ upstream?: string;
425
+ ahead?: number;
426
+ behind?: number;
427
+ };
428
+ /**
429
+ * Options for git status
430
+ */
431
+ type StatusOpts = {
432
+ /** Porcelain output format version (1 or 2) */
433
+ porcelain?: 1 | 2;
434
+ /** How to show untracked files */
435
+ untracked?: 'no' | 'normal' | 'all';
436
+ /** Give the output in verbose format */
437
+ verbose?: boolean;
438
+ /** Show stash information */
439
+ showStash?: boolean;
440
+ /** Compute ahead/behind counts for the branch */
441
+ aheadBehind?: boolean;
442
+ /** Use NUL as line terminator */
443
+ nullTerminated?: boolean;
444
+ /** How to show ignored files */
445
+ ignored?: 'traditional' | 'no' | 'matching';
446
+ /** How to handle submodules */
447
+ ignoreSubmodules?: 'none' | 'untracked' | 'dirty' | 'all';
448
+ /** Do not detect renames */
449
+ noRenames?: boolean;
450
+ /** Detect renames (optionally with similarity threshold) */
451
+ findRenames?: boolean | number;
452
+ };
453
+ /**
454
+ * Commit information
455
+ */
456
+ type Commit = {
457
+ hash: string;
458
+ abbrevHash: string;
459
+ parents: string[];
460
+ author: {
461
+ name: string;
462
+ email: string;
463
+ timestamp: number;
464
+ };
465
+ committer: {
466
+ name: string;
467
+ email: string;
468
+ timestamp: number;
469
+ };
470
+ subject: string;
471
+ body: string;
472
+ };
473
+ /**
474
+ * Options for git log
475
+ */
476
+ type LogOpts = {
477
+ /** Limit the number of commits to output */
478
+ maxCount?: number;
479
+ /** Skip number of commits before starting to show the output */
480
+ skip?: number;
481
+ /** Show commits more recent than a specific date */
482
+ since?: string | Date;
483
+ /** Show commits older than a specific date */
484
+ until?: string | Date;
485
+ /** Limit commits to those by a specific author */
486
+ author?: string;
487
+ /** Limit commits to those with log message matching the pattern */
488
+ grep?: string;
489
+ /** Pretend as if all refs are listed on the command line */
490
+ all?: boolean;
491
+ /** Follow only the first parent commit upon seeing a merge commit */
492
+ firstParent?: boolean;
493
+ /** Print out the ref name given on the command line by which each commit was reached */
494
+ source?: boolean;
495
+ /** Use mailmap file to map author names */
496
+ useMailmap?: boolean;
497
+ /** If no --decorate-refs is given, pretend as if all refs were included */
498
+ decorateRefs?: string;
499
+ /** Do not include refs matching the pattern */
500
+ decorateRefsExclude?: string;
501
+ /** Print out the ref names of any commits that are shown */
502
+ decorate?: 'short' | 'full' | 'auto' | 'no';
503
+ /** Generate a diffstat */
504
+ stat?: boolean;
505
+ /** Output only the last line of the stat */
506
+ shortstat?: boolean;
507
+ /** Show only names of changed files */
508
+ nameOnly?: boolean;
509
+ /** Show only names and status of changed files */
510
+ nameStatus?: boolean;
511
+ /** Show only merge commits */
512
+ merges?: boolean;
513
+ /** Do not show merge commits */
514
+ noMerges?: boolean;
515
+ /** Only display commits that are ancestors of the specified commit */
516
+ ancestryPath?: boolean;
517
+ /** Output commits in reverse order */
518
+ reverse?: boolean;
519
+ /** Alias for since */
520
+ after?: string | Date;
521
+ /** Alias for until */
522
+ before?: string | Date;
523
+ /** Revision or revision range to show (e.g., 'main', 'HEAD~5..HEAD', 'v1.0.0') */
524
+ ref?: string;
525
+ };
526
+ /**
527
+ * Options for git fetch
528
+ */
529
+ type FetchOpts = {
530
+ /** Remote name to fetch from */
531
+ remote?: string;
532
+ /** Refspec(s) to fetch */
533
+ refspec?: string | string[];
534
+ /** Remove remote-tracking refs that no longer exist on the remote */
535
+ prune?: boolean;
536
+ /** Fetch all tags from the remote */
537
+ tags?: boolean;
538
+ /** Limit fetching to the specified number of commits */
539
+ depth?: number;
540
+ /** Be more verbose */
541
+ verbose?: boolean;
542
+ /** Operate quietly (suppress progress reporting) */
543
+ quiet?: boolean;
544
+ /** Fetch from all remotes */
545
+ all?: boolean;
546
+ /** Set upstream tracking for the fetched branches */
547
+ setUpstream?: boolean;
548
+ /** Append ref names and object names of fetched refs to .git/FETCH_HEAD */
549
+ append?: boolean;
550
+ /** Use atomic transaction to update refs */
551
+ atomic?: boolean;
552
+ /** Force update of local branches */
553
+ force?: boolean;
554
+ /** Allow fetching from multiple remotes */
555
+ multiple?: boolean;
556
+ /** Do not fetch any tags */
557
+ noTags?: boolean;
558
+ /** Number of parallel children for fetching submodules */
559
+ jobs?: number;
560
+ /** Modify the configured refspec to place all refs into refs/prefetch/ */
561
+ prefetch?: boolean;
562
+ /** Also prune tags that are no longer on the remote */
563
+ pruneTags?: boolean;
564
+ /** Fetch submodules recursively */
565
+ recurseSubmodules?: boolean | 'yes' | 'on-demand' | 'no';
566
+ /** Dry run - show what would be done without making changes */
567
+ dryRun?: boolean;
568
+ /** Allow updating FETCH_HEAD */
569
+ writeFetchHead?: boolean;
570
+ /** Keep downloaded pack */
571
+ keep?: boolean;
572
+ /** Allow updating the current branch head */
573
+ updateHeadOk?: boolean;
574
+ /** Deepen a shallow repository by date */
575
+ shallowSince?: string | Date;
576
+ /** Deepen a shallow repository excluding specified revision */
577
+ shallowExclude?: string | string[];
578
+ /** Deepen a shallow repository by specified number of commits */
579
+ deepen?: number;
580
+ /** Convert a shallow repository to a complete one */
581
+ unshallow?: boolean;
582
+ /** Re-fetch all objects even if we already have them */
583
+ refetch?: boolean;
584
+ /** Update shallow boundary if new refs need it */
585
+ updateShallow?: boolean;
586
+ /** Override the default refspec */
587
+ refmap?: string;
588
+ /** Use IPv4 addresses only */
589
+ ipv4?: boolean;
590
+ /** Use IPv6 addresses only */
591
+ ipv6?: boolean;
592
+ /** Partial clone filter specification */
593
+ filter?: string;
594
+ /** Check for forced updates */
595
+ showForcedUpdates?: boolean;
596
+ /** Write commit graph after fetching */
597
+ writeCommitGraph?: boolean;
598
+ };
599
+ /**
600
+ * Force with lease options for git push
601
+ */
602
+ type ForceWithLeaseOpts = {
603
+ /** Reference name to check (e.g., 'refs/heads/main') */
604
+ refname: string;
605
+ /** Expected value of the ref (commit hash) */
606
+ expect?: string;
607
+ };
608
+ /**
609
+ * Options for git push
610
+ */
611
+ type PushOpts = {
612
+ /** Remote name to push to */
613
+ remote?: string;
614
+ /** Refspec(s) to push */
615
+ refspec?: string | string[];
616
+ /** Force updates even if they are not fast-forward */
617
+ force?: boolean;
618
+ /**
619
+ * Force with lease - safer force push that fails if remote has been updated
620
+ * - true: use default behavior (check current remote ref)
621
+ * - ForceWithLeaseOpts: specify refname and optional expected value
622
+ */
623
+ forceWithLease?: boolean | ForceWithLeaseOpts;
624
+ /** Push all tags */
625
+ tags?: boolean;
626
+ /** Set upstream tracking for the pushed branches */
627
+ setUpstream?: boolean;
628
+ /** Bypass pre-push hook */
629
+ noVerify?: boolean;
630
+ /**
631
+ * GPG-sign the push (for signed pushes)
632
+ * - true: sign with default key
633
+ * - 'if-asked': sign only if server supports and requests it
634
+ */
635
+ signed?: boolean | 'if-asked';
636
+ /** Be more verbose */
637
+ verbose?: boolean;
638
+ /** Operate quietly (suppress progress reporting) */
639
+ quiet?: boolean;
640
+ /** Override the default repository */
641
+ repo?: string;
642
+ /** Push all branches */
643
+ all?: boolean;
644
+ /** Push all branches (alias for all) */
645
+ branches?: boolean;
646
+ /** Mirror mode - push all refs */
647
+ mirror?: boolean;
648
+ /** Delete the specified refs from the remote */
649
+ deleteRefs?: boolean;
650
+ /** Dry run - show what would be pushed without pushing */
651
+ dryRun?: boolean;
652
+ /** Force only if the remote tip is included in local history */
653
+ forceIfIncludes?: boolean;
654
+ /** Push submodules recursively */
655
+ recurseSubmodules?: 'check' | 'on-demand' | 'only' | 'no';
656
+ /** Use thin pack transfer */
657
+ thin?: boolean;
658
+ /** Prune remote-tracking branches that are deleted locally */
659
+ prune?: boolean;
660
+ /** Push all refs under refs/tags with the commits */
661
+ followTags?: boolean;
662
+ /** Use atomic transaction to update refs */
663
+ atomic?: boolean;
664
+ /** Transmit push options to the server */
665
+ pushOption?: string | string[];
666
+ /** Use IPv4 addresses only */
667
+ ipv4?: boolean;
668
+ /** Use IPv6 addresses only */
669
+ ipv6?: boolean;
670
+ };
671
+ /**
672
+ * Options for git add
673
+ */
674
+ type AddOpts = {
675
+ /** Add all files (including untracked) */
676
+ all?: boolean;
677
+ /** Dry run - show what would be added */
678
+ dryRun?: boolean;
679
+ /** Add modified and deleted files, but not untracked */
680
+ update?: boolean;
681
+ /** Force add of ignored files */
682
+ force?: boolean;
683
+ /** Add changes interactively (not supported - use raw) */
684
+ interactive?: never;
685
+ /** Add changes in patch mode (not supported - use raw) */
686
+ patch?: never;
687
+ /** Be verbose */
688
+ verbose?: boolean;
689
+ /** Record only the fact that the path will be added later */
690
+ intentToAdd?: boolean;
691
+ /** Apply the clean process freshly to all tracked files */
692
+ renormalize?: boolean;
693
+ /** Ignore removal of files from working tree */
694
+ ignoreRemoval?: boolean;
695
+ /** Don't add files, just refresh their stat info in the index */
696
+ refresh?: boolean;
697
+ /** If some files could not be added, continue adding others */
698
+ ignoreErrors?: boolean;
699
+ /** Don't report missing files (with --dry-run) */
700
+ ignoreMissing?: boolean;
701
+ /** Allow updating index entries outside of sparse-checkout cone */
702
+ sparse?: boolean;
703
+ /** Override the executable bit of the listed files */
704
+ chmod?: '+x' | '-x';
705
+ /** Read pathspecs from file instead of command line */
706
+ pathspecFromFile?: string;
707
+ };
708
+ /**
709
+ * Branch information
710
+ */
711
+ type BranchInfo = {
712
+ name: string;
713
+ current: boolean;
714
+ commit: string;
715
+ upstream?: string;
716
+ gone?: boolean;
717
+ };
718
+ /**
719
+ * Options for git branch
720
+ */
721
+ type BranchOpts = {
722
+ /** List all branches (including remote) */
723
+ all?: boolean;
724
+ /** List remote branches only */
725
+ remotes?: boolean;
726
+ /** Show verbose info */
727
+ verbose?: boolean;
728
+ /** Suppress informational messages */
729
+ quiet?: boolean;
730
+ /** Only list branches that contain the specified commit */
731
+ contains?: string;
732
+ /** Only list branches that don't contain the specified commit */
733
+ noContains?: string;
734
+ /** Abbreviate object names to specified length */
735
+ abbrev?: number;
736
+ /** Only list branches whose tips are reachable from the specified commit */
737
+ merged?: string;
738
+ /** Only list branches whose tips are not reachable from the specified commit */
739
+ noMerged?: string;
740
+ /** Sorting key (e.g., -committerdate, refname) */
741
+ sort?: string;
742
+ /** Only list branches that point at the specified object */
743
+ pointsAt?: string;
744
+ /** Sorting and filtering are case insensitive */
745
+ ignoreCase?: boolean;
746
+ };
747
+ /**
748
+ * Options for creating a branch
749
+ */
750
+ type BranchCreateOpts = {
751
+ /** Start point (commit, branch, or tag) */
752
+ startPoint?: string;
753
+ /** Force creation (overwrite existing) */
754
+ force?: boolean;
755
+ /** Set up tracking */
756
+ track?: boolean;
757
+ /** Set up upstream configuration for the new branch */
758
+ setUpstreamTo?: string;
759
+ /** Create the branch's reflog */
760
+ createReflog?: boolean;
761
+ /** Also update submodules */
762
+ recurseSubmodules?: boolean;
763
+ };
764
+ /**
765
+ * Options for deleting a branch
766
+ */
767
+ type BranchDeleteOpts = {
768
+ /** Force delete (even if not merged) */
769
+ force?: boolean;
770
+ /** Delete remote-tracking branch */
771
+ remote?: boolean;
772
+ };
773
+ /**
774
+ * Options for git checkout (branch switching mode)
775
+ *
776
+ * Used for: `git checkout <branch>`
777
+ */
778
+ type CheckoutBranchOpts = {
779
+ /** Force checkout (discard local changes) */
780
+ force?: boolean;
781
+ /** Create new branch */
782
+ createBranch?: boolean;
783
+ /** Start point for new branch */
784
+ startPoint?: string;
785
+ /** Track remote branch */
786
+ track?: boolean;
787
+ /** Create or reset and checkout branch (like -b but forces) */
788
+ forceCreateBranch?: boolean;
789
+ /** Create reflog for new branch */
790
+ createReflog?: boolean;
791
+ /** Try to guess remote tracking branch if target not found */
792
+ guess?: boolean;
793
+ /** Suppress progress reporting */
794
+ quiet?: boolean;
795
+ /** Update submodules */
796
+ recurseSubmodules?: boolean;
797
+ /** Merge local modifications with the new branch */
798
+ merge?: boolean;
799
+ /** Conflict style for merge conflicts */
800
+ conflict?: 'merge' | 'diff3' | 'zdiff3';
801
+ /** Detach HEAD at specified commit */
802
+ detach?: boolean;
803
+ /** Create new orphan branch */
804
+ orphan?: boolean;
805
+ /** Silently overwrite ignored files */
806
+ overwriteIgnore?: boolean;
807
+ /** Ignore if branch is checked out in other worktrees */
808
+ ignoreOtherWorktrees?: boolean;
809
+ };
810
+ /**
811
+ * Options for git checkout (pathspec mode)
812
+ *
813
+ * Used for: `git checkout [<tree-ish>] -- <pathspec>...`
814
+ */
815
+ type CheckoutPathOpts = {
816
+ /** Force checkout (discard local changes) */
817
+ force?: boolean;
818
+ /** Source tree-ish to checkout from (default: index) */
819
+ source?: string;
820
+ /** Suppress progress reporting */
821
+ quiet?: boolean;
822
+ /** Allow overlapping paths when checking out from tree-ish */
823
+ overlay?: boolean;
824
+ /** Check out 'our' version for unmerged files */
825
+ ours?: boolean;
826
+ /** Check out 'their' version for unmerged files */
827
+ theirs?: boolean;
828
+ /** Read pathspecs from file instead of command line */
829
+ pathspecFromFile?: string;
830
+ };
831
+ /**
832
+ * Options for git checkout (legacy combined type)
833
+ * @deprecated Use CheckoutBranchOpts or CheckoutPathOpts for type safety
834
+ */
835
+ type CheckoutOpts = CheckoutBranchOpts & CheckoutPathOpts;
836
+ /**
837
+ * Options for git commit
838
+ */
839
+ type CommitOpts = {
840
+ /** Commit message */
841
+ message?: string;
842
+ /** Allow empty commit */
843
+ allowEmpty?: boolean;
844
+ /** Amend previous commit */
845
+ amend?: boolean;
846
+ /** Add all tracked modified files */
847
+ all?: boolean;
848
+ /** Author name and email */
849
+ author?: string;
850
+ /** Override commit date */
851
+ date?: string | Date;
852
+ /** Do not create commit, just update message */
853
+ dryRun?: boolean;
854
+ /** Bypass pre-commit and commit-msg hooks */
855
+ noVerify?: boolean;
856
+ /** GPG-sign the commit with the default key */
857
+ gpgSign?: boolean;
858
+ /** Do not GPG-sign the commit (override commit.gpgSign config) */
859
+ noGpgSign?: boolean;
860
+ /** Suppress commit summary message */
861
+ quiet?: boolean;
862
+ /** Show unified diff between HEAD and working tree */
863
+ verbose?: boolean;
864
+ /** Read commit message from file */
865
+ file?: string;
866
+ /** Take existing commit message and re-edit it */
867
+ reeditMessage?: string;
868
+ /** Take existing commit message and reuse it */
869
+ reuseMessage?: string;
870
+ /** Create a fixup commit for the specified commit */
871
+ fixup?: string;
872
+ /** Create a squash commit for the specified commit */
873
+ squash?: string;
874
+ /** Override author date and ignore cached author identity */
875
+ resetAuthor?: boolean;
876
+ /** Add trailers to the commit message */
877
+ trailer?: string | string[];
878
+ /** Add Signed-off-by trailer */
879
+ signoff?: boolean;
880
+ /** How to clean up the commit message */
881
+ cleanup?: 'strip' | 'whitespace' | 'verbatim' | 'scissors' | 'default';
882
+ /** Before committing, also stage specified paths */
883
+ include?: boolean;
884
+ /** Commit only specified paths, ignoring staged changes */
885
+ only?: boolean;
886
+ /** Bypass post-rewrite hook */
887
+ noPostRewrite?: boolean;
888
+ /** How to show untracked files */
889
+ untrackedFiles?: 'no' | 'normal' | 'all';
890
+ /** Read pathspecs from file instead of command line */
891
+ pathspecFromFile?: string;
892
+ /** Allow commit with empty message */
893
+ allowEmptyMessage?: boolean;
894
+ };
895
+ /**
896
+ * Commit result
897
+ */
898
+ type CommitResult = {
899
+ /** Commit hash */
900
+ hash: string;
901
+ /** Branch name */
902
+ branch: string;
903
+ /** Commit message summary */
904
+ summary: string;
905
+ /** Files changed */
906
+ filesChanged: number;
907
+ /** Insertions */
908
+ insertions: number;
909
+ /** Deletions */
910
+ deletions: number;
911
+ };
912
+ /**
913
+ * Options for git diff
914
+ */
915
+ type DiffOpts = {
916
+ /** Compare staged changes */
917
+ staged?: boolean;
918
+ /** Show stat only */
919
+ stat?: boolean;
920
+ /** Show name only */
921
+ nameOnly?: boolean;
922
+ /** Show name and status */
923
+ nameStatus?: boolean;
924
+ /** Number of context lines */
925
+ context?: number;
926
+ /** Ignore whitespace changes */
927
+ ignoreWhitespace?: boolean;
928
+ /** Pathspecs to filter */
929
+ paths?: string[];
930
+ /** Use NUL as line terminator */
931
+ nullTerminated?: boolean;
932
+ /** Generate patch output */
933
+ patch?: boolean;
934
+ /** Generate patch and raw format together */
935
+ patchWithRaw?: boolean;
936
+ /** Show number of added/deleted lines in decimal notation */
937
+ numstat?: boolean;
938
+ /** Generate patch and diffstat together */
939
+ patchWithStat?: boolean;
940
+ /** Show full 40-byte hexadecimal object name in diff */
941
+ fullIndex?: boolean;
942
+ /** Abbreviate object names to specified length */
943
+ abbrev?: number;
944
+ /** Swap two inputs (show reverse diff) */
945
+ reverse?: boolean;
946
+ /** Detect rewrites (optionally with threshold like '50%') */
947
+ detectRewrites?: boolean | string;
948
+ /** Detect renames (optionally with threshold like '50%') */
949
+ detectRenames?: boolean | string;
950
+ /** Detect copies (optionally with threshold like '50%') */
951
+ detectCopies?: boolean | string;
952
+ /** Find copies harder (inspects unmodified files as source) */
953
+ findCopiesHarder?: boolean;
954
+ /** Rename limit threshold */
955
+ renameLimit?: number;
956
+ /** Look for string added/removed in a change (pickaxe) */
957
+ pickaxe?: string;
958
+ /** Show all files that changed, not just those with pickaxe match */
959
+ pickaxeAll?: boolean;
960
+ /** Treat all files as text */
961
+ text?: boolean;
962
+ /** Show changes relative to a merge base */
963
+ mergeBase?: string;
964
+ /** Compare two paths on filesystem (not in repository) */
965
+ noIndex?: boolean;
966
+ /** Show word diff */
967
+ wordDiff?: 'color' | 'plain' | 'porcelain' | 'none';
968
+ };
969
+ /**
970
+ * Diff file entry
971
+ */
972
+ type DiffEntry = {
973
+ path: string;
974
+ status: 'A' | 'D' | 'M' | 'R' | 'C' | 'T' | 'U' | 'X';
975
+ oldPath?: string;
976
+ additions?: number;
977
+ deletions?: number;
978
+ };
979
+ /**
980
+ * Diff result
981
+ */
982
+ type DiffResult = {
983
+ files: DiffEntry[];
984
+ raw?: string;
985
+ };
986
+ /**
987
+ * Options for git merge
988
+ */
989
+ type MergeOpts = {
990
+ /** Merge message */
991
+ message?: string;
992
+ /** Fast-forward behavior */
993
+ ff?: 'only' | 'no' | boolean;
994
+ /** Squash merge */
995
+ squash?: boolean;
996
+ /** No commit after merge */
997
+ noCommit?: boolean;
998
+ /** Strategy to use */
999
+ strategy?: string;
1000
+ /** Strategy options */
1001
+ strategyOption?: string | string[];
1002
+ /** Abort merge */
1003
+ abort?: boolean;
1004
+ /** Continue merge */
1005
+ continue?: boolean;
1006
+ /** Bypass pre-merge-commit hook */
1007
+ noVerify?: boolean;
1008
+ /** Do not show diffstat at end of merge */
1009
+ noDiffstat?: boolean;
1010
+ /** Show diffstat at end of merge */
1011
+ stat?: boolean;
1012
+ /** Show compact summary of changed files */
1013
+ compactSummary?: boolean;
1014
+ /** Add log of commits being merged (optionally with count) */
1015
+ log?: boolean | number;
1016
+ /** How to clean up the commit message */
1017
+ cleanup?: 'strip' | 'whitespace' | 'verbatim' | 'scissors' | 'default';
1018
+ /** Automatically update rerere state */
1019
+ rerereAutoupdate?: boolean;
1020
+ /** Verify that commit is signed with a valid key */
1021
+ verifySignatures?: boolean;
1022
+ /** Be verbose */
1023
+ verbose?: boolean;
1024
+ /** Be quiet */
1025
+ quiet?: boolean;
1026
+ /** Quit the current in-progress merge without cleanup */
1027
+ quit?: boolean;
1028
+ /** Allow merging histories that do not share a common ancestor */
1029
+ allowUnrelatedHistories?: boolean;
1030
+ /** GPG-sign the merge commit (optionally with key id) */
1031
+ gpgSign?: boolean | string;
1032
+ /** Automatically stash before merge and unstash after */
1033
+ autostash?: boolean;
1034
+ /** Silently overwrite ignored files */
1035
+ overwriteIgnore?: boolean;
1036
+ /** Add Signed-off-by trailer */
1037
+ signoff?: boolean;
1038
+ /** Use custom branch name in merge commit message */
1039
+ intoName?: string;
1040
+ };
1041
+ /**
1042
+ * Merge result
1043
+ */
1044
+ type MergeResult = {
1045
+ success: boolean;
1046
+ hash?: string;
1047
+ conflicts?: string[];
1048
+ fastForward?: boolean;
1049
+ };
1050
+ /**
1051
+ * Options for git pull
1052
+ */
1053
+ type PullOpts = {
1054
+ /** Remote name */
1055
+ remote?: string;
1056
+ /** Branch to pull */
1057
+ branch?: string;
1058
+ /** Rebase instead of merge */
1059
+ rebase?: boolean | 'merges' | 'interactive';
1060
+ /** Fast-forward behavior */
1061
+ ff?: 'only' | 'no' | boolean;
1062
+ /** Fetch tags */
1063
+ tags?: boolean;
1064
+ /** Prune remote-tracking refs */
1065
+ prune?: boolean;
1066
+ /** Progress callback */
1067
+ onProgress?: (progress: GitProgress) => void;
1068
+ /** Be verbose */
1069
+ verbose?: boolean;
1070
+ /** Be quiet */
1071
+ quiet?: boolean;
1072
+ /** Fetch submodules recursively */
1073
+ recurseSubmodules?: boolean | 'yes' | 'on-demand' | 'no';
1074
+ /** Do not show diffstat at end of merge */
1075
+ noStat?: boolean;
1076
+ /** Show diffstat at end of merge */
1077
+ stat?: boolean;
1078
+ /** Show compact summary of changed files */
1079
+ compactSummary?: boolean;
1080
+ /** Add log of commits being merged (optionally with count) */
1081
+ log?: boolean | number;
1082
+ /** Add Signed-off-by trailer */
1083
+ signoff?: boolean;
1084
+ /** Squash merge */
1085
+ squash?: boolean;
1086
+ /** Perform merge and commit (or not) */
1087
+ commit?: boolean;
1088
+ /** How to clean up the commit message */
1089
+ cleanup?: string;
1090
+ /** Run hooks or not */
1091
+ verify?: boolean;
1092
+ /** Verify that commit is signed with a valid key */
1093
+ verifySignatures?: boolean;
1094
+ /** Automatically stash before pull and unstash after */
1095
+ autostash?: boolean;
1096
+ /** Merge strategy to use */
1097
+ strategy?: string;
1098
+ /** Strategy options */
1099
+ strategyOption?: string | string[];
1100
+ /** GPG-sign the merge commit (optionally with key id) */
1101
+ gpgSign?: boolean | string;
1102
+ /** Allow merging histories that do not share a common ancestor */
1103
+ allowUnrelatedHistories?: boolean;
1104
+ /** Fetch from all remotes */
1105
+ all?: boolean;
1106
+ /** Append ref names and object names to FETCH_HEAD */
1107
+ append?: boolean;
1108
+ /** Force update of local branches */
1109
+ force?: boolean;
1110
+ /** Number of parallel children for fetching submodules */
1111
+ jobs?: number;
1112
+ /** Dry run */
1113
+ dryRun?: boolean;
1114
+ /** Keep downloaded pack */
1115
+ keep?: boolean;
1116
+ /** Limit fetching depth */
1117
+ depth?: number;
1118
+ /** Deepen shallow clone since date */
1119
+ shallowSince?: string | Date;
1120
+ /** Deepen shallow clone excluding revision */
1121
+ shallowExclude?: string | string[];
1122
+ /** Deepen shallow clone by specified commits */
1123
+ deepen?: number;
1124
+ /** Convert shallow repository to complete one */
1125
+ unshallow?: boolean;
1126
+ /** Update shallow boundary if new refs need it */
1127
+ updateShallow?: boolean;
1128
+ /** Use IPv4 addresses only */
1129
+ ipv4?: boolean;
1130
+ /** Use IPv6 addresses only */
1131
+ ipv6?: boolean;
1132
+ /** Set upstream tracking for the current branch */
1133
+ setUpstream?: boolean;
1134
+ };
1135
+ /**
1136
+ * Options for git reset
1137
+ */
1138
+ type ResetOpts = {
1139
+ /** Reset mode */
1140
+ mode?: 'soft' | 'mixed' | 'hard' | 'merge' | 'keep';
1141
+ /** Be quiet (report only errors) */
1142
+ quiet?: boolean;
1143
+ /** Skip refreshing the index after reset */
1144
+ noRefresh?: boolean;
1145
+ /** Reset submodules */
1146
+ recurseSubmodules?: boolean;
1147
+ /** Record intention to add unstaged files */
1148
+ intentToAdd?: boolean;
1149
+ /** Read pathspecs from file instead of command line */
1150
+ pathspecFromFile?: string;
1151
+ };
1152
+ /**
1153
+ * Options for git rm
1154
+ */
1155
+ type RmOpts = {
1156
+ /** Force removal */
1157
+ force?: boolean;
1158
+ /** Remove from index only (keep in working tree) */
1159
+ cached?: boolean;
1160
+ /** Allow recursive removal */
1161
+ recursive?: boolean;
1162
+ /** Dry run */
1163
+ dryRun?: boolean;
1164
+ /** Suppress output */
1165
+ quiet?: boolean;
1166
+ /** Exit with zero status even if no files matched */
1167
+ ignoreUnmatch?: boolean;
1168
+ /** Allow removing files outside of sparse-checkout cone */
1169
+ sparse?: boolean;
1170
+ /** Read pathspecs from file instead of command line */
1171
+ pathspecFromFile?: string;
1172
+ };
1173
+ /**
1174
+ * Stash entry
1175
+ */
1176
+ type StashEntry = {
1177
+ index: number;
1178
+ message: string;
1179
+ branch?: string;
1180
+ commit: string;
1181
+ };
1182
+ /**
1183
+ * Options for git stash push
1184
+ */
1185
+ type StashPushOpts = {
1186
+ /** Stash message */
1187
+ message?: string;
1188
+ /** Include untracked files */
1189
+ includeUntracked?: boolean;
1190
+ /** Keep index */
1191
+ keepIndex?: boolean;
1192
+ /** Specific paths to stash */
1193
+ paths?: string[];
1194
+ /** Stash only staged changes */
1195
+ staged?: boolean;
1196
+ /** Suppress output */
1197
+ quiet?: boolean;
1198
+ /** Stash all files including untracked and ignored */
1199
+ all?: boolean;
1200
+ /** Read pathspecs from file instead of command line */
1201
+ pathspecFromFile?: string;
1202
+ };
1203
+ /**
1204
+ * Options for git stash pop/apply
1205
+ */
1206
+ type StashApplyOpts = {
1207
+ /** Stash index to apply */
1208
+ index?: number;
1209
+ /** Try to reinstate index */
1210
+ reinstateIndex?: boolean;
1211
+ };
1212
+ /**
1213
+ * Options for git switch
1214
+ */
1215
+ type SwitchOpts = {
1216
+ /** Create new branch */
1217
+ create?: boolean;
1218
+ /** Force create (overwrite existing) */
1219
+ forceCreate?: boolean;
1220
+ /** Discard local changes */
1221
+ discard?: boolean;
1222
+ /** Start point for new branch */
1223
+ startPoint?: string;
1224
+ /** Track remote branch */
1225
+ track?: boolean;
1226
+ /** Detach HEAD */
1227
+ detach?: boolean;
1228
+ /** Try to guess remote tracking branch if target not found */
1229
+ guess?: boolean;
1230
+ /** Suppress progress reporting */
1231
+ quiet?: boolean;
1232
+ /** Update submodules */
1233
+ recurseSubmodules?: boolean;
1234
+ /** Merge local modifications with the new branch */
1235
+ merge?: boolean;
1236
+ /** Conflict style for merge conflicts */
1237
+ conflict?: 'merge' | 'diff3' | 'zdiff3';
1238
+ /** Force switch (throw away local modifications) */
1239
+ force?: boolean;
1240
+ /** Create new orphan branch */
1241
+ orphan?: boolean;
1242
+ /** Silently overwrite ignored files */
1243
+ overwriteIgnore?: boolean;
1244
+ /** Ignore if branch is checked out in other worktrees */
1245
+ ignoreOtherWorktrees?: boolean;
1246
+ };
1247
+ /**
1248
+ * Tag information
1249
+ */
1250
+ type TagInfo = {
1251
+ name: string;
1252
+ commit: string;
1253
+ message?: string;
1254
+ tagger?: {
1255
+ name: string;
1256
+ email: string;
1257
+ date: Date;
1258
+ };
1259
+ annotated: boolean;
1260
+ };
1261
+ /**
1262
+ * Options for git tag (list)
1263
+ */
1264
+ type TagListOpts = {
1265
+ /** List pattern */
1266
+ pattern?: string;
1267
+ /** Sort by */
1268
+ sort?: string;
1269
+ /** Print n lines of tag message */
1270
+ lines?: number;
1271
+ /** Only list tags that contain the specified commit */
1272
+ contains?: string;
1273
+ /** Only list tags that don't contain the specified commit */
1274
+ noContains?: string;
1275
+ /** Only list tags whose tips are reachable from the specified commit */
1276
+ merged?: string;
1277
+ /** Only list tags whose tips are not reachable from the specified commit */
1278
+ noMerged?: string;
1279
+ /** Only list tags that point at the specified object */
1280
+ pointsAt?: string;
1281
+ /** Sorting and filtering are case insensitive */
1282
+ ignoreCase?: boolean;
1283
+ };
1284
+ /**
1285
+ * Options for creating a tag
1286
+ */
1287
+ type TagCreateOpts = {
1288
+ /** Tag message (creates annotated tag) */
1289
+ message?: string;
1290
+ /** Force (overwrite existing tag) */
1291
+ force?: boolean;
1292
+ /** Commit to tag */
1293
+ commit?: string;
1294
+ /** GPG-sign the tag with the default key */
1295
+ sign?: boolean;
1296
+ /** Read tag message from file */
1297
+ file?: string;
1298
+ /** Add trailers to the tag message */
1299
+ trailer?: string | string[];
1300
+ /** How to clean up the tag message */
1301
+ cleanup?: string;
1302
+ /** Key to use for GPG signing */
1303
+ localUser?: string;
1304
+ /** Create the tag's reflog */
1305
+ createReflog?: boolean;
1306
+ };
1307
+ /**
1308
+ * Options for git cherry-pick
1309
+ */
1310
+ type CherryPickOpts = {
1311
+ /** Edit commit message */
1312
+ edit?: boolean;
1313
+ /** No commit after cherry-pick */
1314
+ noCommit?: boolean;
1315
+ /** Add signoff */
1316
+ signoff?: boolean;
1317
+ /** Mainline parent number for merge commits */
1318
+ mainline?: number;
1319
+ /** Strategy to use */
1320
+ strategy?: string;
1321
+ /** Abort cherry-pick */
1322
+ abort?: boolean;
1323
+ /** Continue cherry-pick */
1324
+ continue?: boolean;
1325
+ /** Skip current commit */
1326
+ skip?: boolean;
1327
+ /** Bypass pre-commit hook */
1328
+ noVerify?: boolean;
1329
+ /** How to clean up the commit message */
1330
+ cleanup?: 'strip' | 'whitespace' | 'verbatim' | 'scissors' | 'default';
1331
+ /** Automatically update rerere state */
1332
+ rerereAutoupdate?: boolean;
1333
+ /** Strategy options */
1334
+ strategyOption?: string | string[];
1335
+ /** GPG-sign the commit (optionally with key id) */
1336
+ gpgSign?: boolean | string;
1337
+ /** Append (cherry picked from ...) line to original message */
1338
+ appendCommitName?: boolean;
1339
+ /** Fast-forward if possible */
1340
+ ff?: boolean;
1341
+ /** Allow recording empty commits */
1342
+ allowEmpty?: boolean;
1343
+ /** Allow empty commit messages */
1344
+ allowEmptyMessage?: boolean;
1345
+ /** How to handle originally empty commits */
1346
+ empty?: 'drop' | 'keep' | 'stop';
1347
+ };
1348
+ /**
1349
+ * Options for git clean
1350
+ */
1351
+ type CleanOpts = {
1352
+ /** Force clean */
1353
+ force?: boolean;
1354
+ /** Remove directories too */
1355
+ directories?: boolean;
1356
+ /** Remove ignored files too */
1357
+ ignored?: boolean;
1358
+ /** Only remove ignored files */
1359
+ onlyIgnored?: boolean;
1360
+ /** Dry run */
1361
+ dryRun?: boolean;
1362
+ /** Paths to clean */
1363
+ paths?: string[];
1364
+ /** Suppress output */
1365
+ quiet?: boolean;
1366
+ /** Exclude files matching pattern */
1367
+ exclude?: string | string[];
1368
+ };
1369
+ /**
1370
+ * Options for git mv
1371
+ */
1372
+ type MvOpts = {
1373
+ /** Force move */
1374
+ force?: boolean;
1375
+ /** Dry run */
1376
+ dryRun?: boolean;
1377
+ /** Be verbose */
1378
+ verbose?: boolean;
1379
+ /** Skip errors */
1380
+ skipErrors?: boolean;
1381
+ /** Allow moving files outside of sparse-checkout cone */
1382
+ sparse?: boolean;
1383
+ };
1384
+ /**
1385
+ * Options for git rebase
1386
+ */
1387
+ type RebaseOpts = {
1388
+ /** Upstream branch */
1389
+ upstream?: string;
1390
+ /** Onto target */
1391
+ onto?: string;
1392
+ /** Interactive rebase (not supported - use raw) */
1393
+ interactive?: never;
1394
+ /** Preserve merges */
1395
+ rebaseMerges?: boolean;
1396
+ /** Abort rebase */
1397
+ abort?: boolean;
1398
+ /** Continue rebase */
1399
+ continue?: boolean;
1400
+ /** Skip current commit */
1401
+ skip?: boolean;
1402
+ /** Bypass pre-rebase hook */
1403
+ noVerify?: boolean;
1404
+ /** Keep the commits at the base unchanged */
1405
+ keepBase?: boolean;
1406
+ /** Be quiet */
1407
+ quiet?: boolean;
1408
+ /** Be verbose */
1409
+ verbose?: boolean;
1410
+ /** Add signoff */
1411
+ signoff?: boolean;
1412
+ /** Set committer date to author date */
1413
+ committerDateIsAuthorDate?: boolean;
1414
+ /** Set author date to committer date */
1415
+ resetAuthorDate?: boolean;
1416
+ /** Ignore whitespace differences */
1417
+ ignoreWhitespace?: boolean;
1418
+ /** Whitespace handling mode */
1419
+ whitespace?: string;
1420
+ /** Force rebase even if already up-to-date */
1421
+ forceRebase?: boolean;
1422
+ /** Create merge commit instead of rebasing */
1423
+ noFf?: boolean;
1424
+ /** Use apply strategy */
1425
+ apply?: boolean;
1426
+ /** Automatically update rerere state */
1427
+ rerereAutoupdate?: boolean;
1428
+ /** How to handle empty commits */
1429
+ empty?: 'drop' | 'keep' | 'ask';
1430
+ /** Automatically squash fixup commits */
1431
+ autosquash?: boolean;
1432
+ /** Update refs that point to rebased commits */
1433
+ updateRefs?: boolean;
1434
+ /** GPG-sign commits */
1435
+ gpgSign?: boolean | string;
1436
+ /** Automatically stash/unstash */
1437
+ autostash?: boolean;
1438
+ /** Execute command after each commit */
1439
+ exec?: string;
1440
+ /** Use fork point for base */
1441
+ forkPoint?: boolean;
1442
+ /** Merge strategy */
1443
+ strategy?: string;
1444
+ /** Strategy options */
1445
+ strategyOption?: string | string[];
1446
+ /** Rebase from root commit */
1447
+ root?: boolean;
1448
+ /** Reschedule failed exec commands */
1449
+ rescheduleFailedExec?: boolean;
1450
+ /** Reapply cherry-picks */
1451
+ reapplyCherryPicks?: boolean;
1452
+ };
1453
+ /**
1454
+ * Options for git restore
1455
+ */
1456
+ type RestoreOpts = {
1457
+ /** Restore staged files */
1458
+ staged?: boolean;
1459
+ /** Restore working tree files */
1460
+ worktree?: boolean;
1461
+ /** Source to restore from */
1462
+ source?: string;
1463
+ /** Ours or theirs for conflicts */
1464
+ ours?: boolean;
1465
+ theirs?: boolean;
1466
+ /** Ignore unmerged entries */
1467
+ ignoreUnmerged?: boolean;
1468
+ /** Allow overlay mode (default is no-overlay) */
1469
+ overlay?: boolean;
1470
+ /** Suppress output */
1471
+ quiet?: boolean;
1472
+ /** Recurse into submodules */
1473
+ recurseSubmodules?: boolean;
1474
+ /** Show progress */
1475
+ progress?: boolean;
1476
+ /** Attempt to recreate merge conflicts */
1477
+ merge?: boolean;
1478
+ /** Conflict style for merge conflicts */
1479
+ conflict?: 'merge' | 'diff3' | 'zdiff3';
1480
+ /** Ignore skip-worktree bits */
1481
+ ignoreSkipWorktreeBits?: boolean;
1482
+ /** Read pathspecs from file */
1483
+ pathspecFromFile?: string;
1484
+ };
1485
+ /**
1486
+ * Options for git revert
1487
+ */
1488
+ type RevertOpts = {
1489
+ /** Edit commit message */
1490
+ edit?: boolean;
1491
+ /** No commit after revert */
1492
+ noCommit?: boolean;
1493
+ /** Mainline parent number for merge commits */
1494
+ mainline?: number;
1495
+ /** Abort revert */
1496
+ abort?: boolean;
1497
+ /** Continue revert */
1498
+ continue?: boolean;
1499
+ /** Skip current commit */
1500
+ skip?: boolean;
1501
+ /** Bypass pre-commit hook */
1502
+ noVerify?: boolean;
1503
+ /** How to clean up the commit message */
1504
+ cleanup?: 'strip' | 'whitespace' | 'verbatim' | 'scissors' | 'default';
1505
+ /** Add signoff */
1506
+ signoff?: boolean;
1507
+ /** Automatically update rerere state */
1508
+ rerereAutoupdate?: boolean;
1509
+ /** Merge strategy */
1510
+ strategy?: string;
1511
+ /** Strategy options */
1512
+ strategyOption?: string | string[];
1513
+ /** GPG-sign the commit */
1514
+ gpgSign?: boolean | string;
1515
+ /** Add reference to reverted commit */
1516
+ reference?: boolean;
1517
+ };
1518
+ /**
1519
+ * Options for git show
1520
+ */
1521
+ type ShowOpts = {
1522
+ /** Show stat only */
1523
+ stat?: boolean;
1524
+ /** Show name only */
1525
+ nameOnly?: boolean;
1526
+ /** Show name and status */
1527
+ nameStatus?: boolean;
1528
+ /** Format string */
1529
+ format?: string;
1530
+ /** Suppress output */
1531
+ quiet?: boolean;
1532
+ /** Show source ref for each commit */
1533
+ source?: boolean;
1534
+ /** Use mailmap for author/committer names */
1535
+ useMailmap?: boolean;
1536
+ /** Only decorate refs matching pattern */
1537
+ decorateRefs?: string;
1538
+ /** Exclude refs matching pattern from decoration */
1539
+ decorateRefsExclude?: string;
1540
+ /** Decorate style */
1541
+ decorate?: 'short' | 'full' | 'auto' | 'no';
1542
+ };
1543
+ /**
1544
+ * Options that return a single path from rev-parse
1545
+ *
1546
+ * These options are mutually exclusive - only one can be specified at a time.
1547
+ */
1548
+ type RevParsePathQuery = {
1549
+ gitDir: true;
1550
+ } | {
1551
+ absoluteGitDir: true;
1552
+ } | {
1553
+ gitCommonDir: true;
1554
+ } | {
1555
+ showToplevel: true;
1556
+ } | {
1557
+ showCdup: true;
1558
+ } | {
1559
+ showPrefix: true;
1560
+ } | {
1561
+ showSuperprojectWorkingTree: true;
1562
+ } | {
1563
+ sharedIndexPath: true;
1564
+ } | {
1565
+ gitPath: string;
1566
+ } | {
1567
+ resolveGitDir: string;
1568
+ };
1569
+ /**
1570
+ * Options that return a boolean from rev-parse
1571
+ *
1572
+ * These options are mutually exclusive - only one can be specified at a time.
1573
+ */
1574
+ type RevParseBooleanQuery = {
1575
+ isInsideGitDir: true;
1576
+ } | {
1577
+ isInsideWorkTree: true;
1578
+ } | {
1579
+ isBareRepository: true;
1580
+ } | {
1581
+ isShallowRepository: true;
1582
+ };
1583
+ /**
1584
+ * Common options for list queries
1585
+ */
1586
+ type RevParseListOpts = {
1587
+ /** Exclude refs matching pattern */
1588
+ exclude?: string;
1589
+ /**
1590
+ * Exclude refs that would be hidden by the specified operation.
1591
+ * - 'fetch': hidden by `transfer.hideRefs` for fetch
1592
+ * - 'receive': hidden by `receive.hideRefs`
1593
+ * - 'uploadpack': hidden by `uploadpack.hideRefs`
1594
+ */
1595
+ excludeHidden?: 'fetch' | 'receive' | 'uploadpack';
1596
+ };
1597
+ /**
1598
+ * Options that return a list of refs from rev-parse
1599
+ *
1600
+ * These options are mutually exclusive - only one can be specified at a time.
1601
+ * For branches/tags/remotes, you can pass `true` to list all, or a pattern string to filter.
1602
+ */
1603
+ type RevParseListQuery = ({
1604
+ all: true;
1605
+ } & RevParseListOpts) | ({
1606
+ branches: true | string;
1607
+ } & RevParseListOpts) | ({
1608
+ tags: true | string;
1609
+ } & RevParseListOpts) | ({
1610
+ remotes: true | string;
1611
+ } & RevParseListOpts) | ({
1612
+ glob: string;
1613
+ } & RevParseListOpts) | {
1614
+ disambiguate: string;
1615
+ };
1616
+ /**
1617
+ * Options that modify how a ref is resolved
1618
+ */
1619
+ type RevParseRefOpts = {
1620
+ /** Verify that the parameter can be turned into a raw SHA-1 (stricter parsing) */
1621
+ verify?: boolean;
1622
+ /** Shorten to unique prefix (true for default length, number for specific length) */
1623
+ short?: boolean | number;
1624
+ /** Output abbreviated ref name (e.g., "main" instead of SHA) */
1625
+ abbrevRef?: boolean | 'strict' | 'loose';
1626
+ /** Output in a form as close to the original input as possible */
1627
+ symbolic?: boolean;
1628
+ /** Output full refname (e.g., "refs/heads/main" instead of "main") */
1629
+ symbolicFullName?: boolean;
1630
+ /**
1631
+ * In --verify mode, exit silently with non-zero status on invalid input
1632
+ * instead of outputting an error message. Only works with --verify.
1633
+ */
1634
+ quiet?: boolean;
1635
+ };
1636
+ /**
1637
+ * Options that return other information from rev-parse
1638
+ */
1639
+ type RevParseOtherQuery = {
1640
+ showObjectFormat: true | 'storage' | 'input' | 'output';
1641
+ } | {
1642
+ showRefFormat: true;
1643
+ } | {
1644
+ localEnvVars: true;
1645
+ };
1646
+ /**
1647
+ * Path format option for path queries
1648
+ */
1649
+ type RevParsePathFormat = 'absolute' | 'relative';
1650
+ /**
1651
+ * Additional options for path queries
1652
+ */
1653
+ type RevParsePathOpts = {
1654
+ /** Control whether paths are output as absolute or relative */
1655
+ pathFormat?: RevParsePathFormat;
1656
+ };
1657
+ /**
1658
+ * Options for git submodule
1659
+ */
1660
+ type SubmoduleOpts = {
1661
+ /** Recursive operation */
1662
+ recursive?: boolean;
1663
+ /** Initialize submodules */
1664
+ init?: boolean;
1665
+ /** Remote tracking branch */
1666
+ remote?: boolean;
1667
+ /** Force update */
1668
+ force?: boolean;
1669
+ /** Do not fetch from remotes */
1670
+ noFetch?: boolean;
1671
+ /** Checkout the superproject's recorded commit */
1672
+ checkout?: boolean;
1673
+ /** Merge the commit into the current branch */
1674
+ merge?: boolean;
1675
+ /** Rebase the current branch onto the commit */
1676
+ rebase?: boolean;
1677
+ /** Use recommended shallow clone depth */
1678
+ recommendShallow?: boolean;
1679
+ /** Reference repository for shared clone */
1680
+ reference?: string;
1681
+ /** Clone only one branch */
1682
+ singleBranch?: boolean;
1683
+ /** Partial clone filter specification */
1684
+ filter?: string;
1685
+ };
1686
+ /**
1687
+ * Options for adding a submodule
1688
+ */
1689
+ type SubmoduleAddOpts = {
1690
+ /** Branch to track */
1691
+ branch?: string;
1692
+ /** Force addition */
1693
+ force?: boolean;
1694
+ /** Submodule name (if different from path) */
1695
+ name?: string;
1696
+ /** Reference repository */
1697
+ reference?: string;
1698
+ /** Depth for shallow clone */
1699
+ depth?: number;
1700
+ };
1701
+ /**
1702
+ * Options for deinitializing a submodule
1703
+ */
1704
+ type SubmoduleDeinitOpts = {
1705
+ /** Force deinitialization */
1706
+ force?: boolean;
1707
+ /** Deinitialize all submodules */
1708
+ all?: boolean;
1709
+ };
1710
+ /**
1711
+ * Options for submodule status
1712
+ */
1713
+ type SubmoduleStatusOpts = {
1714
+ /** Check submodules recursively */
1715
+ recursive?: boolean;
1716
+ };
1717
+ /**
1718
+ * Options for submodule summary
1719
+ */
1720
+ type SubmoduleSummaryOpts = {
1721
+ /** Limit to the specified number of commits */
1722
+ limit?: number;
1723
+ /** Show files in the summary */
1724
+ files?: boolean;
1725
+ };
1726
+ /**
1727
+ * Options for submodule foreach
1728
+ */
1729
+ type SubmoduleForeachOpts = {
1730
+ /** Run the command recursively in nested submodules */
1731
+ recursive?: boolean;
1732
+ };
1733
+ /**
1734
+ * Options for submodule sync
1735
+ */
1736
+ type SubmoduleSyncOpts = {
1737
+ /** Sync recursively in nested submodules */
1738
+ recursive?: boolean;
1739
+ };
1740
+ /**
1741
+ * Options for submodule set-branch
1742
+ */
1743
+ type SubmoduleSetBranchOpts = {
1744
+ /** Set the default tracking branch */
1745
+ default?: boolean;
1746
+ };
1747
+ /**
1748
+ * Submodule information
1749
+ */
1750
+ type SubmoduleInfo = {
1751
+ name: string;
1752
+ path: string;
1753
+ url: string;
1754
+ branch?: string;
1755
+ commit: string;
1756
+ };
1757
+ /**
1758
+ * LFS status information
1759
+ */
1760
+ type LfsStatus = {
1761
+ files: Array<{
1762
+ name: string;
1763
+ size: number;
1764
+ status: 'checkout' | 'download' | 'upload' | 'unknown';
1765
+ }>;
1766
+ };
1767
+ /**
1768
+ * Options for LFS pull
1769
+ */
1770
+ type LfsPullOpts = {
1771
+ remote?: string;
1772
+ ref?: string;
1773
+ include?: string[];
1774
+ exclude?: string[];
1775
+ };
1776
+ /**
1777
+ * Options for LFS push
1778
+ */
1779
+ type LfsPushOpts = {
1780
+ remote?: string;
1781
+ ref?: string;
1782
+ /** Dry run - show what would be pushed without actually pushing */
1783
+ dryRun?: boolean;
1784
+ /** Push specified object IDs (OID hashes) instead of all objects */
1785
+ objectId?: string | string[];
1786
+ };
1787
+ /**
1788
+ * Options for LFS status
1789
+ */
1790
+ type LfsStatusOpts = {
1791
+ json?: boolean;
1792
+ /** Machine-readable output */
1793
+ porcelain?: boolean;
1794
+ };
1795
+ /**
1796
+ * Options for LFS prune
1797
+ */
1798
+ type LfsPruneOpts = {
1799
+ /** Force prune (remove unreferenced objects immediately) */
1800
+ force?: boolean;
1801
+ /** Dry run - show what would be pruned without actually pruning */
1802
+ dryRun?: boolean;
1803
+ /** Verify remote copies before pruning */
1804
+ verifyRemote?: boolean;
1805
+ /** Verify unreferenced copies */
1806
+ verifyUnreferenced?: boolean;
1807
+ /** Only prune objects not accessed recently */
1808
+ recent?: boolean;
1809
+ /** Show verbose output */
1810
+ verbose?: boolean;
1811
+ /** When unverified behavior: panic or ignore */
1812
+ whenUnverified?: 'panic' | 'ignore';
1813
+ };
1814
+ /**
1815
+ * Options for LFS fetch
1816
+ */
1817
+ type LfsFetchOpts = {
1818
+ /** Fetch all LFS objects for all refs */
1819
+ all?: boolean;
1820
+ /** Include patterns */
1821
+ include?: string | string[];
1822
+ /** Exclude patterns */
1823
+ exclude?: string | string[];
1824
+ /** Only fetch recent objects */
1825
+ recent?: boolean;
1826
+ /** Prune old objects after fetch */
1827
+ prune?: boolean;
1828
+ /** Refetch objects even if already local */
1829
+ refetch?: boolean;
1830
+ /** Dry run - show what would be fetched */
1831
+ dryRun?: boolean;
1832
+ /** Output in JSON format */
1833
+ json?: boolean;
1834
+ /** Remote to fetch from */
1835
+ remote?: string;
1836
+ /** Refs to fetch */
1837
+ refs?: string | string[];
1838
+ };
1839
+ /**
1840
+ * Options for repository-level LFS install
1841
+ *
1842
+ * Used with `repo.lfs.install()` for repository-local LFS configuration.
1843
+ *
1844
+ * @remarks
1845
+ * Internally runs `git lfs install --local` by default, which writes to
1846
+ * the repository's .git/config file. This ensures LFS configuration is
1847
+ * scoped to the current repository only.
1848
+ *
1849
+ * For global (user-level) or system-wide installation, use `git.lfs.install()` instead.
1850
+ */
1851
+ type RepoLfsInstallOpts = {
1852
+ /** Overwrite existing hooks */
1853
+ force?: boolean;
1854
+ /**
1855
+ * Install for worktree only (instead of repository)
1856
+ *
1857
+ * @remarks
1858
+ * Internally uses `--worktree` flag instead of `--local`.
1859
+ * Requires Git 2.20.0+ with worktreeConfig extension enabled.
1860
+ */
1861
+ worktree?: boolean;
1862
+ /** Skip smudge filter (don't download during checkout) */
1863
+ skipSmudge?: boolean;
1864
+ };
1865
+ /**
1866
+ * Options for repository-level LFS uninstall
1867
+ *
1868
+ * Used with `repo.lfs.uninstall()` for repository-local LFS configuration removal.
1869
+ *
1870
+ * @remarks
1871
+ * Internally runs `git lfs uninstall --local` by default, which modifies
1872
+ * the repository's .git/config file only.
1873
+ *
1874
+ * For global or system-wide uninstallation, use `git.lfs.uninstall()` instead.
1875
+ */
1876
+ type RepoLfsUninstallOpts = {
1877
+ /**
1878
+ * Uninstall for worktree only (instead of repository)
1879
+ *
1880
+ * @remarks
1881
+ * Internally uses `--worktree` flag instead of `--local`.
1882
+ * Requires Git 2.20.0+ with worktreeConfig extension enabled.
1883
+ */
1884
+ worktree?: boolean;
1885
+ };
1886
+ /**
1887
+ * LFS file entry
1888
+ */
1889
+ type LfsFileEntry = {
1890
+ /** File path */
1891
+ path: string;
1892
+ /** Object ID (SHA-256) */
1893
+ oid: string;
1894
+ /** File size in bytes */
1895
+ size?: number;
1896
+ /** Checkout status */
1897
+ status: 'checked-out' | 'not-checked-out';
1898
+ };
1899
+ /**
1900
+ * Options for LFS ls-files
1901
+ */
1902
+ type LfsLsFilesOpts = {
1903
+ /** Show full OID (not abbreviated) */
1904
+ long?: boolean;
1905
+ /** Show file sizes */
1906
+ size?: boolean;
1907
+ /** Show debug information */
1908
+ debug?: boolean;
1909
+ /** Show all LFS files (not just current ref) */
1910
+ all?: boolean;
1911
+ /** Show deleted files */
1912
+ deleted?: boolean;
1913
+ /** Include patterns */
1914
+ include?: string | string[];
1915
+ /** Exclude patterns */
1916
+ exclude?: string | string[];
1917
+ /** Show filenames only */
1918
+ nameOnly?: boolean;
1919
+ /** Output in JSON format */
1920
+ json?: boolean;
1921
+ /** Ref to list files for */
1922
+ ref?: string;
1923
+ };
1924
+ /**
1925
+ * LFS track entry
1926
+ */
1927
+ type LfsTrackEntry = {
1928
+ /** Pattern being tracked */
1929
+ pattern: string;
1930
+ /** Source file (e.g., .gitattributes) */
1931
+ source: string;
1932
+ /** Whether files matching pattern are lockable */
1933
+ lockable: boolean;
1934
+ };
1935
+ /**
1936
+ * Options for LFS track
1937
+ */
1938
+ type LfsTrackOpts = {
1939
+ /** Show verbose output */
1940
+ verbose?: boolean;
1941
+ /** Dry run - show what would be tracked */
1942
+ dryRun?: boolean;
1943
+ /** Treat pattern as filename, not glob */
1944
+ filename?: boolean;
1945
+ /** Make files lockable */
1946
+ lockable?: boolean;
1947
+ /** Make files not lockable */
1948
+ notLockable?: boolean;
1949
+ /** Don't exclude from export */
1950
+ noExcluded?: boolean;
1951
+ /** Don't modify .gitattributes */
1952
+ noModifyAttrs?: boolean;
1953
+ };
1954
+ /**
1955
+ * LFS lock entry
1956
+ */
1957
+ type LfsLockEntry = {
1958
+ /** Lock ID */
1959
+ id: string;
1960
+ /** Locked file path */
1961
+ path: string;
1962
+ /** Lock owner */
1963
+ owner: {
1964
+ name: string;
1965
+ };
1966
+ /** Lock timestamp */
1967
+ lockedAt: Date;
1968
+ };
1969
+ /**
1970
+ * Options for LFS lock
1971
+ */
1972
+ type LfsLockOpts = {
1973
+ /** Remote name */
1974
+ remote?: string;
1975
+ /** Output in JSON format */
1976
+ json?: boolean;
1977
+ };
1978
+ /**
1979
+ * Options for LFS unlock
1980
+ */
1981
+ type LfsUnlockOpts = {
1982
+ /** Remote name */
1983
+ remote?: string;
1984
+ /** Force unlock (even if owned by another user) */
1985
+ force?: boolean;
1986
+ /** Unlock by ID instead of path */
1987
+ id?: string;
1988
+ /** Output in JSON format */
1989
+ json?: boolean;
1990
+ };
1991
+ /**
1992
+ * Options for LFS locks
1993
+ */
1994
+ type LfsLocksOpts = {
1995
+ /** Remote name */
1996
+ remote?: string;
1997
+ /** Filter by lock ID */
1998
+ id?: string;
1999
+ /** Filter by path */
2000
+ path?: string;
2001
+ /** Show local cache only */
2002
+ local?: boolean;
2003
+ /** Show cached locks */
2004
+ cached?: boolean;
2005
+ /** Verify locks with server */
2006
+ verify?: boolean;
2007
+ /** Limit number of results */
2008
+ limit?: number;
2009
+ /** Output in JSON format */
2010
+ json?: boolean;
2011
+ };
2012
+ /**
2013
+ * Options for LFS checkout
2014
+ */
2015
+ type LfsCheckoutOpts = {
2016
+ /** Use base version for conflicts */
2017
+ base?: boolean;
2018
+ /** Use ours version for conflicts */
2019
+ ours?: boolean;
2020
+ /** Use theirs version for conflicts */
2021
+ theirs?: boolean;
2022
+ /** Write to file instead of working tree */
2023
+ to?: string;
2024
+ /** Include patterns */
2025
+ include?: string | string[];
2026
+ /** Exclude patterns */
2027
+ exclude?: string | string[];
2028
+ };
2029
+ /**
2030
+ * Options for LFS migrate info
2031
+ */
2032
+ type LfsMigrateInfoOpts = {
2033
+ /** Only show files above this size */
2034
+ above?: string | number;
2035
+ /** Show top N files */
2036
+ top?: number;
2037
+ /** Size unit (b, kb, mb, gb) */
2038
+ unit?: 'b' | 'kb' | 'mb' | 'gb';
2039
+ /** Show pointer files */
2040
+ pointers?: 'follow' | 'no-follow' | 'ignore';
2041
+ /** Fix up tracking patterns */
2042
+ fixup?: boolean;
2043
+ /** Include patterns */
2044
+ include?: string | string[];
2045
+ /** Exclude patterns */
2046
+ exclude?: string | string[];
2047
+ /** Include refs */
2048
+ includeRef?: string | string[];
2049
+ /** Exclude refs */
2050
+ excludeRef?: string | string[];
2051
+ /** Skip fetching from remote */
2052
+ skipFetch?: boolean;
2053
+ /** Operate on all refs */
2054
+ everything?: boolean;
2055
+ /** Confirm destructive operation */
2056
+ yesReally?: boolean;
2057
+ };
2058
+ /**
2059
+ * Options for LFS migrate import
2060
+ */
2061
+ type LfsMigrateImportOpts = LfsMigrateInfoOpts & {
2062
+ /** Show verbose output */
2063
+ verbose?: boolean;
2064
+ /** Write object map file */
2065
+ objectMap?: string;
2066
+ /** Don't rewrite history */
2067
+ noRewrite?: boolean;
2068
+ /** Commit message for fixup */
2069
+ message?: string;
2070
+ /** Object IDs to import */
2071
+ object?: string | string[];
2072
+ };
2073
+ /**
2074
+ * Options for LFS migrate export
2075
+ */
2076
+ type LfsMigrateExportOpts = LfsMigrateInfoOpts & {
2077
+ /** Show verbose output */
2078
+ verbose?: boolean;
2079
+ /** Write object map file */
2080
+ objectMap?: string;
2081
+ /** Remote name */
2082
+ remote?: string;
2083
+ };
2084
+ /**
2085
+ * LFS environment info
2086
+ */
2087
+ type LfsEnvInfo = {
2088
+ /** LFS version */
2089
+ lfsVersion: string;
2090
+ /** Git version */
2091
+ gitVersion: string;
2092
+ /** Endpoint URL */
2093
+ endpoint: string;
2094
+ /** SSH endpoint */
2095
+ sshEndpoint?: string;
2096
+ /** Local working directory */
2097
+ localWorkingDir?: string;
2098
+ /** Local git directory */
2099
+ localGitDir?: string;
2100
+ /** Local git storage directory */
2101
+ localGitStorageDir?: string;
2102
+ /** Local media directory */
2103
+ localMediaDir?: string;
2104
+ /** Local reference directories */
2105
+ localReferenceDirs?: string;
2106
+ /** Temp directory */
2107
+ tempDir?: string;
2108
+ /** Concurrent transfers */
2109
+ concurrentTransfers?: number;
2110
+ /** TUS transfers enabled */
2111
+ tusTransfers?: boolean;
2112
+ /** Basic transfers only */
2113
+ basicTransfersOnly?: boolean;
2114
+ /** Skip download errors */
2115
+ skipDownloadErrors?: boolean;
2116
+ /** Fetch recent always */
2117
+ fetchRecentAlways?: boolean;
2118
+ /** Fetch recent refs days */
2119
+ fetchRecentRefsDays?: number;
2120
+ /** Fetch recent commits days */
2121
+ fetchRecentCommitsDays?: number;
2122
+ /** Fetch recent refs include remotes */
2123
+ fetchRecentRefsIncludeRemotes?: boolean;
2124
+ /** Prune offset days */
2125
+ pruneOffsetDays?: number;
2126
+ /** Prune verify remote always */
2127
+ pruneVerifyRemoteAlways?: boolean;
2128
+ /** Prune remote name */
2129
+ pruneRemoteName?: string;
2130
+ /** Access mode for downloads */
2131
+ accessDownload?: string;
2132
+ /** Access mode for uploads */
2133
+ accessUpload?: string;
2134
+ };
2135
+ /**
2136
+ * Options for LFS pre-upload (§10.3)
2137
+ *
2138
+ * Pre-upload allows pushing LFS objects before the refs push,
2139
+ * enabling 2-phase commit patterns for improved reliability.
2140
+ */
2141
+ type LfsPreUploadOpts = {
2142
+ /** Object IDs to upload (if omitted, auto-detect pending objects) */
2143
+ oids?: string[];
2144
+ /** Batch size for upload (default: 50, considers Windows 8KB limit) */
2145
+ batchSize?: number;
2146
+ /** Remote name (default: 'origin') */
2147
+ remote?: string;
2148
+ };
2149
+ /**
2150
+ * Result from LFS pre-upload
2151
+ */
2152
+ type LfsPreUploadResult = {
2153
+ /** Number of objects uploaded */
2154
+ uploadedCount: number;
2155
+ /** Total bytes uploaded */
2156
+ uploadedBytes: number;
2157
+ /** Number of objects skipped (already on remote) */
2158
+ skippedCount: number;
2159
+ };
2160
+ /**
2161
+ * Options for LFS pre-download (§10.3)
2162
+ *
2163
+ * Pre-download allows fetching LFS objects before checkout,
2164
+ * useful for controlled large file management.
2165
+ */
2166
+ type LfsPreDownloadOpts = {
2167
+ /** Object IDs to download (if omitted, auto-detect from ref) */
2168
+ oids?: string[];
2169
+ /** Git ref to get LFS objects for (branch, tag, or commit) */
2170
+ ref?: string;
2171
+ /** Batch size for download (default: 50) */
2172
+ batchSize?: number;
2173
+ /** Remote name (default: 'origin') */
2174
+ remote?: string;
2175
+ };
2176
+ /**
2177
+ * Result from LFS pre-download
2178
+ */
2179
+ type LfsPreDownloadResult = {
2180
+ /** Number of objects downloaded */
2181
+ downloadedCount: number;
2182
+ /** Total bytes downloaded */
2183
+ downloadedBytes: number;
2184
+ /** Number of objects skipped (already local) */
2185
+ skippedCount: number;
2186
+ };
2187
+ /**
2188
+ * Worktree information (§7.4)
2189
+ *
2190
+ * Parsed from `git worktree list --porcelain` output.
2191
+ */
2192
+ type Worktree = {
2193
+ /** Worktree path */
2194
+ path: string;
2195
+ /** HEAD commit hash */
2196
+ head: string;
2197
+ /** Branch name (if checked out) */
2198
+ branch?: string;
2199
+ /** Whether the worktree is locked */
2200
+ locked: boolean;
2201
+ /** Whether the worktree is prunable */
2202
+ prunable: boolean;
2203
+ };
2204
+ /**
2205
+ * Options for adding a worktree
2206
+ */
2207
+ type WorktreeAddOpts = {
2208
+ /**
2209
+ * Commit-ish to checkout (branch, tag, or commit hash)
2210
+ *
2211
+ * @example
2212
+ * ```typescript
2213
+ * // Checkout a specific commit in detached mode
2214
+ * await repo.worktree.add('/tmp/worktree', { detach: true, commitish: 'abc1234' });
2215
+ *
2216
+ * // Checkout a tag
2217
+ * await repo.worktree.add('/tmp/worktree', { detach: true, commitish: 'v1.0.0' });
2218
+ *
2219
+ * // Checkout a branch
2220
+ * await repo.worktree.add('/tmp/worktree', { commitish: 'feature-branch' });
2221
+ * ```
2222
+ */
2223
+ commitish?: string;
2224
+ /** Branch name to create (-b flag) */
2225
+ branch?: string;
2226
+ /** Create detached HEAD */
2227
+ detach?: boolean;
2228
+ /** Track remote branch */
2229
+ track?: boolean;
2230
+ /** Force creation even if branch is already checked out */
2231
+ force?: boolean;
2232
+ /** Checkout the worktree (true) or not (false) */
2233
+ checkout?: boolean;
2234
+ /** Keep the worktree locked after creation */
2235
+ lock?: boolean;
2236
+ /** Create worktree with orphan branch */
2237
+ orphan?: boolean;
2238
+ };
2239
+ /**
2240
+ * Options for removing a worktree
2241
+ */
2242
+ type WorktreeRemoveOpts = {
2243
+ /** Force removal even if dirty */
2244
+ force?: boolean;
2245
+ };
2246
+ /**
2247
+ * Options for pruning worktrees
2248
+ */
2249
+ type WorktreePruneOpts = {
2250
+ /** Show what would be pruned without actually pruning */
2251
+ dryRun?: boolean;
2252
+ /** Show more details */
2253
+ verbose?: boolean;
2254
+ /** Expire worktrees older than the given time */
2255
+ expire?: string;
2256
+ };
2257
+ /**
2258
+ * Options for worktree move
2259
+ */
2260
+ type WorktreeMoveOpts = {
2261
+ /** Force move even if destination exists */
2262
+ force?: boolean;
2263
+ };
2264
+ /**
2265
+ * Options for worktree repair
2266
+ */
2267
+ type WorktreeRepairOpts = {};
2268
+ /**
2269
+ * Options for locking a worktree
2270
+ */
2271
+ type WorktreeLockOpts = {
2272
+ /** Reason for locking */
2273
+ reason?: string;
2274
+ };
2275
+ /**
2276
+ * Worktree operations
2277
+ *
2278
+ * Wraps: `git worktree` subcommands
2279
+ */
2280
+ interface WorktreeOperations {
2281
+ /**
2282
+ * List all worktrees
2283
+ *
2284
+ * Wraps: `git worktree list --porcelain`
2285
+ */
2286
+ list(opts?: ExecOpts): Promise<Worktree[]>;
2287
+ /**
2288
+ * Add a new worktree and return a repository object for it
2289
+ *
2290
+ * Wraps: `git worktree add <path>`
2291
+ *
2292
+ * @returns A WorktreeRepo instance for the newly created worktree
2293
+ */
2294
+ add(path: string, opts?: WorktreeAddOpts & ExecOpts): Promise<WorktreeRepo>;
2295
+ /**
2296
+ * Remove a worktree
2297
+ *
2298
+ * Wraps: `git worktree remove <path>`
2299
+ */
2300
+ remove(path: string, opts?: WorktreeRemoveOpts & ExecOpts): Promise<void>;
2301
+ /**
2302
+ * Prune stale worktree references
2303
+ *
2304
+ * Wraps: `git worktree prune`
2305
+ */
2306
+ prune(opts?: WorktreePruneOpts & ExecOpts): Promise<string[]>;
2307
+ /**
2308
+ * Lock a worktree
2309
+ *
2310
+ * Wraps: `git worktree lock <path>`
2311
+ */
2312
+ lock(path: string, opts?: WorktreeLockOpts & ExecOpts): Promise<void>;
2313
+ /**
2314
+ * Unlock a worktree
2315
+ *
2316
+ * Wraps: `git worktree unlock <path>`
2317
+ */
2318
+ unlock(path: string, opts?: ExecOpts): Promise<void>;
2319
+ /**
2320
+ * Move a worktree to a new location and return a repository object for it
2321
+ *
2322
+ * Wraps: `git worktree move <src> <dst>`
2323
+ *
2324
+ * @returns A WorktreeRepo instance for the worktree at the new location
2325
+ */
2326
+ move(src: string, dst: string, opts?: WorktreeMoveOpts & ExecOpts): Promise<WorktreeRepo>;
2327
+ /**
2328
+ * Repair worktree administrative files
2329
+ *
2330
+ * Wraps: `git worktree repair`
2331
+ */
2332
+ repair(paths?: string[], opts?: ExecOpts): Promise<void>;
2333
+ }
2334
+ /**
2335
+ * LFS operations
2336
+ *
2337
+ * Wraps: `git lfs` subcommands
2338
+ */
2339
+ interface LfsOperations {
2340
+ /**
2341
+ * Pull LFS objects
2342
+ *
2343
+ * Wraps: `git lfs pull`
2344
+ */
2345
+ pull(opts?: LfsPullOpts & ExecOpts): Promise<void>;
2346
+ /**
2347
+ * Push LFS objects
2348
+ *
2349
+ * Wraps: `git lfs push`
2350
+ */
2351
+ push(opts?: LfsPushOpts & ExecOpts): Promise<void>;
2352
+ /**
2353
+ * Get LFS status
2354
+ *
2355
+ * Wraps: `git lfs status`
2356
+ */
2357
+ status(opts?: LfsStatusOpts & ExecOpts): Promise<LfsStatus>;
2358
+ /**
2359
+ * Prune old and unreferenced LFS objects from local storage
2360
+ *
2361
+ * Wraps: `git lfs prune`
2362
+ */
2363
+ prune(opts?: LfsPruneOpts & ExecOpts): Promise<void>;
2364
+ /**
2365
+ * Fetch LFS objects from remote
2366
+ *
2367
+ * Wraps: `git lfs fetch`
2368
+ */
2369
+ fetch(opts?: LfsFetchOpts & ExecOpts): Promise<void>;
2370
+ /**
2371
+ * Install Git LFS hooks for this repository
2372
+ *
2373
+ * Wraps: `git lfs install --local`
2374
+ *
2375
+ * Installs LFS hooks to the repository's .git/config file.
2376
+ * This ensures LFS configuration is scoped to this repository only.
2377
+ *
2378
+ * @remarks
2379
+ * Internally always adds `--local` flag (or `--worktree` if specified).
2380
+ * For global or system-wide installation, use `git.lfs.install()` instead.
2381
+ *
2382
+ * @example
2383
+ * ```typescript
2384
+ * // Install LFS locally for this repository
2385
+ * await repo.lfs.install();
2386
+ *
2387
+ * // Install for worktree only (Git 2.20.0+)
2388
+ * await repo.lfs.install({ worktree: true });
2389
+ * ```
2390
+ */
2391
+ install(opts?: RepoLfsInstallOpts & ExecOpts): Promise<void>;
2392
+ /**
2393
+ * Uninstall Git LFS hooks from this repository
2394
+ *
2395
+ * Wraps: `git lfs uninstall --local`
2396
+ *
2397
+ * Removes LFS hooks from the repository's .git/config file.
2398
+ *
2399
+ * @remarks
2400
+ * Internally always adds `--local` flag (or `--worktree` if specified).
2401
+ * For global or system-wide uninstallation, use `git.lfs.uninstall()` instead.
2402
+ *
2403
+ * @example
2404
+ * ```typescript
2405
+ * // Uninstall LFS from this repository
2406
+ * await repo.lfs.uninstall();
2407
+ * ```
2408
+ */
2409
+ uninstall(opts?: RepoLfsUninstallOpts & ExecOpts): Promise<void>;
2410
+ /**
2411
+ * List LFS files in the repository
2412
+ *
2413
+ * Wraps: `git lfs ls-files`
2414
+ */
2415
+ lsFiles(opts?: LfsLsFilesOpts & ExecOpts): Promise<LfsFileEntry[]>;
2416
+ /**
2417
+ * Track files with LFS
2418
+ *
2419
+ * Wraps: `git lfs track <pattern>...`
2420
+ */
2421
+ track(patterns: string | string[], opts?: LfsTrackOpts & ExecOpts): Promise<void>;
2422
+ /**
2423
+ * List tracked patterns
2424
+ *
2425
+ * Wraps: `git lfs track` (without arguments)
2426
+ */
2427
+ trackList(opts?: ExecOpts): Promise<LfsTrackEntry[]>;
2428
+ /**
2429
+ * Untrack files from LFS
2430
+ *
2431
+ * Wraps: `git lfs untrack <pattern>...`
2432
+ */
2433
+ untrack(patterns: string | string[], opts?: ExecOpts): Promise<void>;
2434
+ /**
2435
+ * Lock a file
2436
+ *
2437
+ * Wraps: `git lfs lock <path>`
2438
+ */
2439
+ lock(path: string, opts?: LfsLockOpts & ExecOpts): Promise<LfsLockEntry>;
2440
+ /**
2441
+ * Unlock a file
2442
+ *
2443
+ * Wraps: `git lfs unlock <path>`
2444
+ */
2445
+ unlock(pathOrId: string, opts?: LfsUnlockOpts & ExecOpts): Promise<void>;
2446
+ /**
2447
+ * List locked files
2448
+ *
2449
+ * Wraps: `git lfs locks`
2450
+ */
2451
+ locks(opts?: LfsLocksOpts & ExecOpts): Promise<LfsLockEntry[]>;
2452
+ /**
2453
+ * Checkout LFS files (replace pointer files with actual content)
2454
+ *
2455
+ * Wraps: `git lfs checkout`
2456
+ */
2457
+ checkout(patterns?: string | string[], opts?: LfsCheckoutOpts & ExecOpts): Promise<void>;
2458
+ /**
2459
+ * Show information about LFS files that would be migrated
2460
+ *
2461
+ * Wraps: `git lfs migrate info`
2462
+ */
2463
+ migrateInfo(opts?: LfsMigrateInfoOpts & ExecOpts): Promise<string>;
2464
+ /**
2465
+ * Import files into LFS
2466
+ *
2467
+ * Wraps: `git lfs migrate import`
2468
+ */
2469
+ migrateImport(opts?: LfsMigrateImportOpts & ExecOpts): Promise<void>;
2470
+ /**
2471
+ * Export files from LFS
2472
+ *
2473
+ * Wraps: `git lfs migrate export`
2474
+ */
2475
+ migrateExport(opts?: LfsMigrateExportOpts & ExecOpts): Promise<void>;
2476
+ /**
2477
+ * Get LFS environment information
2478
+ *
2479
+ * Wraps: `git lfs env`
2480
+ */
2481
+ env(opts?: ExecOpts): Promise<LfsEnvInfo>;
2482
+ /**
2483
+ * Get Git LFS version
2484
+ *
2485
+ * Wraps: `git lfs version`
2486
+ */
2487
+ version(opts?: ExecOpts): Promise<string>;
2488
+ }
2489
+ /**
2490
+ * LFS Extra operations interface (inspired by fs-extra)
2491
+ *
2492
+ * Additional LFS utilities not part of the core LFS commands.
2493
+ * These enable advanced patterns like 2-phase commit/fetch.
2494
+ */
2495
+ interface LfsExtraOperations {
2496
+ /**
2497
+ * Pre-upload LFS objects before refs push (§10.3)
2498
+ *
2499
+ * Enables 2-phase commit pattern for improved reliability with large files.
2500
+ * Objects are uploaded in batches to handle Windows command line limits.
2501
+ *
2502
+ * @example
2503
+ * ```typescript
2504
+ * // Phase 1: Upload LFS objects first
2505
+ * await repo.lfsExtra.preUpload({ onProgress: handleProgress });
2506
+ *
2507
+ * // Phase 2: Create commit
2508
+ * await repo.commit({ message: 'Add large files' });
2509
+ *
2510
+ * // Phase 3: Push refs (LFS already uploaded, so this is fast)
2511
+ * await repo.push();
2512
+ * ```
2513
+ */
2514
+ preUpload(opts?: LfsPreUploadOpts & ExecOpts): Promise<LfsPreUploadResult>;
2515
+ /**
2516
+ * Pre-download LFS objects before checkout (§10.3)
2517
+ *
2518
+ * Enables controlled download of large files before checkout.
2519
+ * Useful when you need to verify available space or report progress separately.
2520
+ */
2521
+ preDownload(opts?: LfsPreDownloadOpts & ExecOpts): Promise<LfsPreDownloadResult>;
2522
+ }
2523
+ /**
2524
+ * Branch operations
2525
+ *
2526
+ * Wraps: `git branch` subcommands
2527
+ */
2528
+ interface BranchOperations {
2529
+ /**
2530
+ * List branches
2531
+ *
2532
+ * Wraps: `git branch --list`
2533
+ */
2534
+ list(opts?: BranchOpts & ExecOpts): Promise<BranchInfo[]>;
2535
+ /**
2536
+ * Get current branch name
2537
+ *
2538
+ * Wraps: `git branch --show-current`
2539
+ */
2540
+ current(opts?: ExecOpts): Promise<string | null>;
2541
+ /**
2542
+ * Create a new branch
2543
+ *
2544
+ * Wraps: `git branch <name>`
2545
+ */
2546
+ create(name: string, opts?: BranchCreateOpts & ExecOpts): Promise<void>;
2547
+ /**
2548
+ * Delete a branch
2549
+ *
2550
+ * Wraps: `git branch -d|-D <name>`
2551
+ */
2552
+ delete(name: string, opts?: BranchDeleteOpts & ExecOpts): Promise<void>;
2553
+ /**
2554
+ * Rename a branch
2555
+ *
2556
+ * Wraps: `git branch -m <old> <new>`
2557
+ */
2558
+ rename(oldName: string, newName: string, opts?: ExecOpts): Promise<void>;
2559
+ }
2560
+ /**
2561
+ * Stash operations
2562
+ *
2563
+ * Wraps: `git stash` subcommands
2564
+ */
2565
+ interface StashOperations {
2566
+ /**
2567
+ * List stash entries
2568
+ *
2569
+ * Wraps: `git stash list`
2570
+ */
2571
+ list(opts?: ExecOpts): Promise<StashEntry[]>;
2572
+ /**
2573
+ * Push changes to stash
2574
+ *
2575
+ * Wraps: `git stash push`
2576
+ */
2577
+ push(opts?: StashPushOpts & ExecOpts): Promise<void>;
2578
+ /**
2579
+ * Pop stash entry
2580
+ *
2581
+ * Wraps: `git stash pop`
2582
+ */
2583
+ pop(opts?: StashApplyOpts & ExecOpts): Promise<void>;
2584
+ /**
2585
+ * Apply stash entry (without removing from stash)
2586
+ *
2587
+ * Wraps: `git stash apply`
2588
+ */
2589
+ apply(opts?: StashApplyOpts & ExecOpts): Promise<void>;
2590
+ /**
2591
+ * Drop a stash entry
2592
+ *
2593
+ * Wraps: `git stash drop`
2594
+ */
2595
+ drop(index?: number, opts?: ExecOpts): Promise<void>;
2596
+ /**
2597
+ * Clear all stash entries
2598
+ *
2599
+ * Wraps: `git stash clear`
2600
+ */
2601
+ clear(opts?: ExecOpts): Promise<void>;
2602
+ }
2603
+ /**
2604
+ * Tag operations
2605
+ *
2606
+ * Wraps: `git tag` subcommands
2607
+ */
2608
+ interface TagOperations {
2609
+ /**
2610
+ * List tags
2611
+ *
2612
+ * Wraps: `git tag --list`
2613
+ */
2614
+ list(opts?: TagListOpts & ExecOpts): Promise<string[]>;
2615
+ /**
2616
+ * Create a tag
2617
+ *
2618
+ * Wraps: `git tag <name>`
2619
+ */
2620
+ create(name: string, opts?: TagCreateOpts & ExecOpts): Promise<void>;
2621
+ /**
2622
+ * Delete a tag
2623
+ *
2624
+ * Wraps: `git tag -d <name>`
2625
+ */
2626
+ delete(name: string, opts?: ExecOpts): Promise<void>;
2627
+ /**
2628
+ * Get tag info
2629
+ *
2630
+ * Wraps: `git tag -v <name>` / `git show <tag>`
2631
+ */
2632
+ show(name: string, opts?: ExecOpts): Promise<TagInfo>;
2633
+ }
2634
+ /**
2635
+ * Remote information
2636
+ */
2637
+ type RemoteInfo = {
2638
+ /** Remote name */
2639
+ name: string;
2640
+ /** Fetch URL */
2641
+ fetchUrl: string;
2642
+ /** Push URL (may differ from fetchUrl) */
2643
+ pushUrl: string;
2644
+ };
2645
+ /**
2646
+ * Options for adding a remote
2647
+ */
2648
+ type RemoteAddOpts = {
2649
+ /** Set up tracking for default branch */
2650
+ track?: string;
2651
+ /** Only fetch specified branches */
2652
+ fetch?: boolean;
2653
+ /** Set up as mirror */
2654
+ mirror?: 'fetch' | 'push';
2655
+ /** Import tags from remote (true) or not (false) */
2656
+ tags?: boolean;
2657
+ };
2658
+ /**
2659
+ * Options for remote set-head
2660
+ */
2661
+ type RemoteSetHeadOpts = {
2662
+ /** Automatically determine remote HEAD */
2663
+ auto?: boolean;
2664
+ /** Delete the symbolic-ref for remote HEAD */
2665
+ delete?: boolean;
2666
+ };
2667
+ /**
2668
+ * Options for remote show
2669
+ */
2670
+ type RemoteShowOpts = {
2671
+ /** Do not query remote heads */
2672
+ noQuery?: boolean;
2673
+ };
2674
+ /**
2675
+ * Options for remote prune
2676
+ */
2677
+ type RemotePruneOpts = {
2678
+ /** Dry run - show what would be pruned */
2679
+ dryRun?: boolean;
2680
+ };
2681
+ /**
2682
+ * Options for remote update
2683
+ */
2684
+ type RemoteUpdateOpts = {
2685
+ /** Prune remote-tracking branches */
2686
+ prune?: boolean;
2687
+ };
2688
+ /**
2689
+ * Options for remote set-branches
2690
+ */
2691
+ type RemoteSetBranchesOpts = {
2692
+ /** Add branches instead of replacing */
2693
+ add?: boolean;
2694
+ };
2695
+ /**
2696
+ * Options for getting/setting remote URL
2697
+ */
2698
+ type RemoteUrlOpts = {
2699
+ /** Target push URL instead of fetch URL */
2700
+ push?: boolean;
2701
+ };
2702
+ /**
2703
+ * Remote operations
2704
+ *
2705
+ * Wraps: `git remote` subcommands
2706
+ */
2707
+ interface RemoteOperations {
2708
+ /**
2709
+ * List remotes
2710
+ *
2711
+ * Wraps: `git remote -v`
2712
+ */
2713
+ list(opts?: ExecOpts): Promise<RemoteInfo[]>;
2714
+ /**
2715
+ * Add a remote
2716
+ *
2717
+ * Wraps: `git remote add <name> <url>`
2718
+ */
2719
+ add(name: string, url: string, opts?: RemoteAddOpts & ExecOpts): Promise<void>;
2720
+ /**
2721
+ * Remove a remote
2722
+ *
2723
+ * Wraps: `git remote remove <name>`
2724
+ */
2725
+ remove(name: string, opts?: ExecOpts): Promise<void>;
2726
+ /**
2727
+ * Rename a remote
2728
+ *
2729
+ * Wraps: `git remote rename <old> <new>`
2730
+ */
2731
+ rename(oldName: string, newName: string, opts?: ExecOpts): Promise<void>;
2732
+ /**
2733
+ * Get remote URL
2734
+ *
2735
+ * Wraps: `git remote get-url <name>`
2736
+ */
2737
+ getUrl(name: string, opts?: RemoteUrlOpts & ExecOpts): Promise<string>;
2738
+ /**
2739
+ * Set remote URL
2740
+ *
2741
+ * Wraps: `git remote set-url <name> <url>`
2742
+ */
2743
+ setUrl(name: string, url: string, opts?: RemoteUrlOpts & ExecOpts): Promise<void>;
2744
+ /**
2745
+ * Set remote HEAD
2746
+ *
2747
+ * Wraps: `git remote set-head <remote> <branch>`
2748
+ */
2749
+ setHead(remote: string, branch?: string, opts?: RemoteSetHeadOpts & ExecOpts): Promise<void>;
2750
+ /**
2751
+ * Show information about a remote
2752
+ *
2753
+ * Wraps: `git remote show <remote>`
2754
+ */
2755
+ show(remote: string, opts?: RemoteShowOpts & ExecOpts): Promise<string>;
2756
+ /**
2757
+ * Prune stale remote-tracking branches
2758
+ *
2759
+ * Wraps: `git remote prune <remote>`
2760
+ */
2761
+ prune(remote: string, opts?: RemotePruneOpts & ExecOpts): Promise<string[]>;
2762
+ /**
2763
+ * Update remotes
2764
+ *
2765
+ * Wraps: `git remote update`
2766
+ */
2767
+ update(remotes?: string[], opts?: RemoteUpdateOpts & ExecOpts): Promise<void>;
2768
+ /**
2769
+ * Set tracked branches for a remote
2770
+ *
2771
+ * Wraps: `git remote set-branches <remote> <branch>...`
2772
+ */
2773
+ setBranches(remote: string, branches: string[], opts?: RemoteSetBranchesOpts & ExecOpts): Promise<void>;
2774
+ }
2775
+ /**
2776
+ * Config entry
2777
+ */
2778
+ type ConfigEntry = {
2779
+ /** Config key (e.g., 'user.name') */
2780
+ key: string;
2781
+ /** Config value */
2782
+ value: string;
2783
+ };
2784
+ /**
2785
+ * Options for config get
2786
+ */
2787
+ type ConfigGetOpts = {
2788
+ /** Get all values for multi-valued key */
2789
+ all?: boolean;
2790
+ /** Type to interpret the value as */
2791
+ type?: 'bool' | 'int' | 'bool-or-int' | 'path' | 'expiry-date' | 'color';
2792
+ /** Default value to use if the key is not set */
2793
+ default?: string;
2794
+ };
2795
+ /**
2796
+ * Options for config set
2797
+ */
2798
+ type ConfigSetOpts = {
2799
+ /** Add value to multi-valued key instead of replacing */
2800
+ add?: boolean;
2801
+ };
2802
+ /**
2803
+ * Options for config list
2804
+ */
2805
+ type ConfigListOpts = {
2806
+ /** Show origin of each value */
2807
+ showOrigin?: boolean;
2808
+ /** Show scope of each value */
2809
+ showScope?: boolean;
2810
+ /** Respect include directives */
2811
+ includes?: boolean;
2812
+ /** Only show config key names */
2813
+ nameOnly?: boolean;
2814
+ };
2815
+ /**
2816
+ * Well-known git config keys with their expected value types
2817
+ *
2818
+ * This provides type safety for common config operations.
2819
+ * For arbitrary keys, use getRaw/setRaw.
2820
+ */
2821
+ type ConfigSchema = {
2822
+ 'user.name': string;
2823
+ 'user.email': string;
2824
+ 'user.signingkey': string;
2825
+ 'core.autocrlf': 'true' | 'false' | 'input';
2826
+ 'core.filemode': 'true' | 'false';
2827
+ 'core.ignorecase': 'true' | 'false';
2828
+ 'core.bare': 'true' | 'false';
2829
+ 'core.logallrefupdates': 'true' | 'false' | 'always';
2830
+ 'core.repositoryformatversion': string;
2831
+ 'core.quotepath': 'true' | 'false';
2832
+ 'core.editor': string;
2833
+ 'core.pager': string;
2834
+ 'core.excludesfile': string;
2835
+ 'core.attributesfile': string;
2836
+ 'core.hooksPath': string;
2837
+ 'core.sshCommand': string;
2838
+ 'init.defaultBranch': string;
2839
+ 'commit.gpgsign': 'true' | 'false';
2840
+ 'commit.template': string;
2841
+ 'tag.gpgsign': 'true' | 'false';
2842
+ 'tag.forcesignannotated': 'true' | 'false';
2843
+ 'push.default': 'nothing' | 'current' | 'upstream' | 'tracking' | 'simple' | 'matching';
2844
+ 'push.followTags': 'true' | 'false';
2845
+ 'push.autoSetupRemote': 'true' | 'false';
2846
+ 'push.gpgSign': 'true' | 'false' | 'if-asked';
2847
+ 'pull.rebase': 'true' | 'false' | 'merges' | 'interactive';
2848
+ 'pull.ff': 'true' | 'false' | 'only';
2849
+ 'fetch.prune': 'true' | 'false';
2850
+ 'fetch.pruneTags': 'true' | 'false';
2851
+ 'merge.ff': 'true' | 'false' | 'only';
2852
+ 'merge.conflictstyle': 'merge' | 'diff3' | 'zdiff3';
2853
+ 'rebase.autoStash': 'true' | 'false';
2854
+ 'rebase.autoSquash': 'true' | 'false';
2855
+ 'rebase.updateRefs': 'true' | 'false';
2856
+ 'diff.algorithm': 'default' | 'minimal' | 'patience' | 'histogram';
2857
+ 'diff.colorMoved': 'no' | 'default' | 'plain' | 'blocks' | 'zebra' | 'dimmed-zebra';
2858
+ 'color.ui': 'auto' | 'always' | 'never' | 'true' | 'false';
2859
+ 'credential.helper': string;
2860
+ 'gpg.format': 'openpgp' | 'x509' | 'ssh';
2861
+ 'gpg.program': string;
2862
+ 'gpg.ssh.program': string;
2863
+ 'gpg.ssh.allowedSignersFile': string;
2864
+ 'http.proxy': string;
2865
+ 'http.sslVerify': 'true' | 'false';
2866
+ 'lfs.fetchexclude': string;
2867
+ 'lfs.fetchinclude': string;
2868
+ 'safe.directory': string;
2869
+ };
2870
+ /**
2871
+ * Known config key names
2872
+ */
2873
+ type ConfigKey = keyof ConfigSchema;
2874
+ /**
2875
+ * Config operations (repository-level)
2876
+ *
2877
+ * Wraps: `git config` subcommands
2878
+ */
2879
+ interface ConfigOperations {
2880
+ /**
2881
+ * Get a typed config value
2882
+ *
2883
+ * Wraps: `git config --get <key>`
2884
+ *
2885
+ * @returns Config value or undefined if not set
2886
+ */
2887
+ get<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<ConfigSchema[K] | undefined>;
2888
+ /**
2889
+ * Get all values for a multi-valued config key
2890
+ *
2891
+ * Wraps: `git config --get-all <key>`
2892
+ */
2893
+ getAll<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<ConfigSchema[K][]>;
2894
+ /**
2895
+ * Set a typed config value
2896
+ *
2897
+ * Wraps: `git config <key> <value>`
2898
+ */
2899
+ set<K extends ConfigKey>(key: K, value: ConfigSchema[K], opts?: ExecOpts): Promise<void>;
2900
+ /**
2901
+ * Add a value to a multi-valued config key
2902
+ *
2903
+ * Wraps: `git config --add <key> <value>`
2904
+ */
2905
+ add<K extends ConfigKey>(key: K, value: ConfigSchema[K], opts?: ExecOpts): Promise<void>;
2906
+ /**
2907
+ * Unset a typed config value
2908
+ *
2909
+ * Wraps: `git config --unset <key>`
2910
+ */
2911
+ unset<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<void>;
2912
+ /**
2913
+ * Get a raw config value (for arbitrary keys)
2914
+ *
2915
+ * Wraps: `git config --get <key>`
2916
+ *
2917
+ * @returns Config value or undefined if not set
2918
+ */
2919
+ getRaw(key: string, opts?: ConfigGetOpts & ExecOpts): Promise<string | string[] | undefined>;
2920
+ /**
2921
+ * Set a raw config value (for arbitrary keys)
2922
+ *
2923
+ * Wraps: `git config <key> <value>`
2924
+ */
2925
+ setRaw(key: string, value: string, opts?: ConfigSetOpts & ExecOpts): Promise<void>;
2926
+ /**
2927
+ * Unset a raw config value (for arbitrary keys)
2928
+ *
2929
+ * Wraps: `git config --unset <key>`
2930
+ */
2931
+ unsetRaw(key: string, opts?: ExecOpts): Promise<void>;
2932
+ /**
2933
+ * List all config values
2934
+ *
2935
+ * Wraps: `git config --list`
2936
+ */
2937
+ list(opts?: ConfigListOpts & ExecOpts): Promise<ConfigEntry[]>;
2938
+ /**
2939
+ * Rename a config section
2940
+ *
2941
+ * Wraps: `git config --rename-section <old> <new>`
2942
+ */
2943
+ renameSection(oldName: string, newName: string, opts?: ExecOpts): Promise<void>;
2944
+ /**
2945
+ * Remove a config section
2946
+ *
2947
+ * Wraps: `git config --remove-section <name>`
2948
+ */
2949
+ removeSection(name: string, opts?: ExecOpts): Promise<void>;
2950
+ }
2951
+ /**
2952
+ * Submodule operations
2953
+ *
2954
+ * Wraps: `git submodule` subcommands
2955
+ */
2956
+ interface SubmoduleOperations {
2957
+ /**
2958
+ * List submodules
2959
+ *
2960
+ * Wraps: `git submodule status`
2961
+ */
2962
+ list(opts?: ExecOpts): Promise<SubmoduleInfo[]>;
2963
+ /**
2964
+ * Initialize submodules
2965
+ *
2966
+ * Wraps: `git submodule init`
2967
+ */
2968
+ init(paths?: string[], opts?: ExecOpts): Promise<void>;
2969
+ /**
2970
+ * Update submodules
2971
+ *
2972
+ * Wraps: `git submodule update`
2973
+ */
2974
+ update(opts?: SubmoduleOpts & ExecOpts): Promise<void>;
2975
+ /**
2976
+ * Add a submodule
2977
+ *
2978
+ * Wraps: `git submodule add <url> <path>`
2979
+ */
2980
+ add(url: string, path: string, opts?: SubmoduleAddOpts & ExecOpts): Promise<void>;
2981
+ /**
2982
+ * Deinitialize a submodule
2983
+ *
2984
+ * Wraps: `git submodule deinit <path>`
2985
+ */
2986
+ deinit(path: string, opts?: SubmoduleDeinitOpts & ExecOpts): Promise<void>;
2987
+ /**
2988
+ * Get submodule status
2989
+ *
2990
+ * Wraps: `git submodule status`
2991
+ */
2992
+ status(paths?: string[], opts?: SubmoduleStatusOpts & ExecOpts): Promise<string>;
2993
+ /**
2994
+ * Get submodule summary
2995
+ *
2996
+ * Wraps: `git submodule summary`
2997
+ */
2998
+ summary(opts?: SubmoduleSummaryOpts & ExecOpts): Promise<string>;
2999
+ /**
3000
+ * Run a command in each submodule
3001
+ *
3002
+ * Wraps: `git submodule foreach <command>`
3003
+ */
3004
+ foreach(command: string, opts?: SubmoduleForeachOpts & ExecOpts): Promise<string>;
3005
+ /**
3006
+ * Sync submodule URL configuration
3007
+ *
3008
+ * Wraps: `git submodule sync`
3009
+ */
3010
+ sync(paths?: string[], opts?: SubmoduleSyncOpts & ExecOpts): Promise<void>;
3011
+ /**
3012
+ * Absorb git directories of submodules into the superproject
3013
+ *
3014
+ * Wraps: `git submodule absorbgitdirs`
3015
+ */
3016
+ absorbGitDirs(opts?: ExecOpts): Promise<void>;
3017
+ /**
3018
+ * Set the branch for a submodule
3019
+ *
3020
+ * Wraps: `git submodule set-branch --branch <branch> -- <path>`
3021
+ */
3022
+ setBranch(path: string, branch: string, opts?: SubmoduleSetBranchOpts & ExecOpts): Promise<void>;
3023
+ /**
3024
+ * Set the URL for a submodule
3025
+ *
3026
+ * Wraps: `git submodule set-url -- <path> <url>`
3027
+ */
3028
+ setUrl(path: string, url: string, opts?: ExecOpts): Promise<void>;
3029
+ }
3030
+ /**
3031
+ * Repository with working directory
3032
+ *
3033
+ * Provides type-safe wrappers for Git commands that operate on repositories
3034
+ * with a working tree. Each method corresponds to a specific Git CLI command
3035
+ * or subcommand.
3036
+ */
3037
+ interface WorktreeRepo extends RepoBase {
3038
+ /** Path to the working directory */
3039
+ readonly workdir: string;
3040
+ /**
3041
+ * Get repository status
3042
+ *
3043
+ * Wraps: `git status`
3044
+ *
3045
+ * @example
3046
+ * ```typescript
3047
+ * const status = await repo.status();
3048
+ * console.log(status.entries); // Changed files
3049
+ * console.log(status.branch); // Current branch
3050
+ * ```
3051
+ */
3052
+ status(opts?: StatusOpts & ExecOpts): Promise<StatusPorcelain>;
3053
+ /**
3054
+ * Get commit log
3055
+ *
3056
+ * Wraps: `git log`
3057
+ *
3058
+ * @example
3059
+ * ```typescript
3060
+ * const commits = await repo.log({ maxCount: 10 });
3061
+ * ```
3062
+ */
3063
+ log(opts?: LogOpts & ExecOpts): Promise<Commit[]>;
3064
+ /**
3065
+ * Fetch from remote
3066
+ *
3067
+ * Wraps: `git fetch`
3068
+ *
3069
+ * @example
3070
+ * ```typescript
3071
+ * await repo.fetch({ remote: 'origin', prune: true });
3072
+ * ```
3073
+ */
3074
+ fetch(opts?: FetchOpts & ExecOpts): Promise<void>;
3075
+ /**
3076
+ * Push to remote
3077
+ *
3078
+ * Wraps: `git push`
3079
+ *
3080
+ * @example
3081
+ * ```typescript
3082
+ * await repo.push({ remote: 'origin', refspec: 'main' });
3083
+ * ```
3084
+ */
3085
+ push(opts?: PushOpts & ExecOpts): Promise<void>;
3086
+ /**
3087
+ * Git LFS operations
3088
+ *
3089
+ * Wraps: `git lfs *` commands
3090
+ */
3091
+ lfs: LfsOperations;
3092
+ /**
3093
+ * Git LFS extra operations (inspired by fs-extra)
3094
+ *
3095
+ * Additional utilities for advanced LFS patterns like 2-phase commit/fetch.
3096
+ */
3097
+ lfsExtra: LfsExtraOperations;
3098
+ /**
3099
+ * Git worktree operations
3100
+ *
3101
+ * Wraps: `git worktree *` commands
3102
+ */
3103
+ worktree: WorktreeOperations;
3104
+ /**
3105
+ * Configure LFS mode for this repository
3106
+ */
3107
+ setLfsMode(mode: LfsMode): void;
3108
+ /**
3109
+ * Add files to the index
3110
+ *
3111
+ * Wraps: `git add`
3112
+ *
3113
+ * @example
3114
+ * ```typescript
3115
+ * await repo.add(['file1.txt', 'file2.txt']);
3116
+ * await repo.add('.', { all: true });
3117
+ * ```
3118
+ */
3119
+ add(paths: string | string[], opts?: AddOpts & ExecOpts): Promise<void>;
3120
+ /**
3121
+ * Git branch operations
3122
+ *
3123
+ * Wraps: `git branch *` commands
3124
+ */
3125
+ branch: BranchOperations;
3126
+ /**
3127
+ * Checkout a branch, tag, or commit (branch switching mode)
3128
+ *
3129
+ * Wraps: `git checkout <branch>`
3130
+ *
3131
+ * @example
3132
+ * ```typescript
3133
+ * await repo.checkout('main');
3134
+ * await repo.checkout('feature', { createBranch: true });
3135
+ * await repo.checkout('feature', { createBranch: true, startPoint: 'origin/main' });
3136
+ * ```
3137
+ */
3138
+ checkout(target: string, opts?: CheckoutBranchOpts & ExecOpts): Promise<void>;
3139
+ /**
3140
+ * Checkout specific files from a tree-ish (pathspec mode)
3141
+ *
3142
+ * Wraps: `git checkout [<tree-ish>] -- <pathspec>...`
3143
+ *
3144
+ * @example
3145
+ * ```typescript
3146
+ * // Restore file from index (discard working tree changes)
3147
+ * await repo.checkout(['file.txt']);
3148
+ *
3149
+ * // Restore file from HEAD
3150
+ * await repo.checkout(['file.txt'], { source: 'HEAD' });
3151
+ *
3152
+ * // Restore file from specific commit
3153
+ * await repo.checkout(['src/'], { source: 'abc123' });
3154
+ *
3155
+ * // Resolve conflict with ours/theirs
3156
+ * await repo.checkout(['conflicted.txt'], { ours: true });
3157
+ * ```
3158
+ */
3159
+ checkout(paths: string[], opts?: CheckoutPathOpts & ExecOpts): Promise<void>;
3160
+ /**
3161
+ * Create a commit
3162
+ *
3163
+ * Wraps: `git commit`
3164
+ *
3165
+ * @example
3166
+ * ```typescript
3167
+ * const result = await repo.commit({ message: 'feat: add new feature' });
3168
+ * console.log(result.hash);
3169
+ * ```
3170
+ */
3171
+ commit(opts?: CommitOpts & ExecOpts): Promise<CommitResult>;
3172
+ /**
3173
+ * Show changes between commits, commit and working tree, etc.
3174
+ *
3175
+ * Wraps: `git diff`
3176
+ *
3177
+ * @example
3178
+ * ```typescript
3179
+ * const diff = await repo.diff('HEAD~1');
3180
+ * const staged = await repo.diff({ staged: true });
3181
+ * ```
3182
+ */
3183
+ diff(target?: string, opts?: DiffOpts & ExecOpts): Promise<DiffResult>;
3184
+ /**
3185
+ * Merge branches
3186
+ *
3187
+ * Wraps: `git merge`
3188
+ *
3189
+ * @example
3190
+ * ```typescript
3191
+ * const result = await repo.merge('feature-branch');
3192
+ * ```
3193
+ */
3194
+ merge(branch: string, opts?: MergeOpts & ExecOpts): Promise<MergeResult>;
3195
+ /**
3196
+ * Pull from remote (fetch + merge/rebase)
3197
+ *
3198
+ * Wraps: `git pull`
3199
+ *
3200
+ * @example
3201
+ * ```typescript
3202
+ * await repo.pull({ remote: 'origin', rebase: true });
3203
+ * ```
3204
+ */
3205
+ pull(opts?: PullOpts & ExecOpts): Promise<void>;
3206
+ /**
3207
+ * Reset current HEAD to the specified state
3208
+ *
3209
+ * Wraps: `git reset`
3210
+ *
3211
+ * @example
3212
+ * ```typescript
3213
+ * await repo.reset('HEAD~1', { hard: true });
3214
+ * await repo.reset({ soft: true });
3215
+ * ```
3216
+ */
3217
+ reset(target?: string, opts?: ResetOpts & ExecOpts): Promise<void>;
3218
+ /**
3219
+ * Remove files from the working tree and from the index
3220
+ *
3221
+ * Wraps: `git rm`
3222
+ *
3223
+ * @example
3224
+ * ```typescript
3225
+ * await repo.rm('file.txt');
3226
+ * await repo.rm('dir/', { recursive: true });
3227
+ * ```
3228
+ */
3229
+ rm(paths: string | string[], opts?: RmOpts & ExecOpts): Promise<void>;
3230
+ /**
3231
+ * Git stash operations
3232
+ *
3233
+ * Wraps: `git stash *` commands
3234
+ */
3235
+ stash: StashOperations;
3236
+ /**
3237
+ * Switch branches
3238
+ *
3239
+ * Wraps: `git switch`
3240
+ *
3241
+ * @example
3242
+ * ```typescript
3243
+ * await repo.switch('main');
3244
+ * await repo.switch('new-branch', { create: true });
3245
+ * ```
3246
+ */
3247
+ switch(branch: string, opts?: SwitchOpts & ExecOpts): Promise<void>;
3248
+ /**
3249
+ * Git tag operations
3250
+ *
3251
+ * Wraps: `git tag *` commands
3252
+ */
3253
+ tag: TagOperations;
3254
+ /**
3255
+ * Apply changes from existing commits
3256
+ *
3257
+ * Wraps: `git cherry-pick`
3258
+ *
3259
+ * @example
3260
+ * ```typescript
3261
+ * await repo.cherryPick('abc123');
3262
+ * await repo.cherryPick(['abc123', 'def456']);
3263
+ * ```
3264
+ */
3265
+ cherryPick(commits: string | string[], opts?: CherryPickOpts & ExecOpts): Promise<void>;
3266
+ /**
3267
+ * Remove untracked files from the working tree
3268
+ *
3269
+ * Wraps: `git clean`
3270
+ *
3271
+ * @example
3272
+ * ```typescript
3273
+ * const removed = await repo.clean({ force: true, directories: true });
3274
+ * ```
3275
+ */
3276
+ clean(opts?: CleanOpts & ExecOpts): Promise<string[]>;
3277
+ /**
3278
+ * Move or rename files
3279
+ *
3280
+ * Wraps: `git mv`
3281
+ *
3282
+ * @example
3283
+ * ```typescript
3284
+ * await repo.mv('old-name.txt', 'new-name.txt');
3285
+ * ```
3286
+ */
3287
+ mv(source: string, destination: string, opts?: MvOpts & ExecOpts): Promise<void>;
3288
+ /**
3289
+ * Reapply commits on top of another base
3290
+ *
3291
+ * Wraps: `git rebase`
3292
+ *
3293
+ * @example
3294
+ * ```typescript
3295
+ * await repo.rebase({ onto: 'main' });
3296
+ * await repo.rebase({ abort: true });
3297
+ * ```
3298
+ */
3299
+ rebase(opts?: RebaseOpts & ExecOpts): Promise<void>;
3300
+ /**
3301
+ * Restore working tree files
3302
+ *
3303
+ * Wraps: `git restore`
3304
+ *
3305
+ * @example
3306
+ * ```typescript
3307
+ * await repo.restore(['file.txt'], { staged: true });
3308
+ * await repo.restore(['.'], { source: 'HEAD' });
3309
+ * ```
3310
+ */
3311
+ restore(paths: string | string[], opts?: RestoreOpts & ExecOpts): Promise<void>;
3312
+ /**
3313
+ * Revert existing commits
3314
+ *
3315
+ * Wraps: `git revert`
3316
+ *
3317
+ * @example
3318
+ * ```typescript
3319
+ * await repo.revert('abc123');
3320
+ * await repo.revert(['abc123', 'def456'], { noCommit: true });
3321
+ * ```
3322
+ */
3323
+ revert(commits: string | string[], opts?: RevertOpts & ExecOpts): Promise<void>;
3324
+ /**
3325
+ * Show various types of objects
3326
+ *
3327
+ * Wraps: `git show`
3328
+ *
3329
+ * @example
3330
+ * ```typescript
3331
+ * const content = await repo.show('HEAD:README.md');
3332
+ * const commitInfo = await repo.show('abc123');
3333
+ * ```
3334
+ */
3335
+ show(object: string, opts?: ShowOpts & ExecOpts): Promise<string>;
3336
+ /**
3337
+ * Parse revision specification and return information about the repository
3338
+ *
3339
+ * Wraps: `git rev-parse`
3340
+ *
3341
+ * This is a versatile command with multiple use cases based on the options provided:
3342
+ *
3343
+ * **Resolve ref to SHA:**
3344
+ * ```typescript
3345
+ * const sha = await repo.revParse('HEAD');
3346
+ * const parentSha = await repo.revParse('HEAD~1');
3347
+ * const short = await repo.revParse('HEAD', { short: true });
3348
+ * const branch = await repo.revParse('HEAD', { abbrevRef: true });
3349
+ * ```
3350
+ *
3351
+ * **Query paths:**
3352
+ * ```typescript
3353
+ * const gitDir = await repo.revParse({ gitDir: true });
3354
+ * const toplevel = await repo.revParse({ showToplevel: true });
3355
+ * ```
3356
+ *
3357
+ * **Query repository state:**
3358
+ * ```typescript
3359
+ * const isShallow = await repo.revParse({ isShallowRepository: true });
3360
+ * const isBare = await repo.revParse({ isBareRepository: true });
3361
+ * ```
3362
+ *
3363
+ * **List refs:**
3364
+ * ```typescript
3365
+ * const allRefs = await repo.revParse({ all: true });
3366
+ * const branches = await repo.revParse({ branches: true });
3367
+ * const featureBranches = await repo.revParse({ branches: 'feature/*' });
3368
+ * ```
3369
+ */
3370
+ revParse(ref: string, opts?: RevParseRefOpts & ExecOpts): Promise<string>;
3371
+ revParse(opts: RevParsePathQuery & RevParsePathOpts & ExecOpts): Promise<string>;
3372
+ revParse(opts: RevParseBooleanQuery & ExecOpts): Promise<boolean>;
3373
+ revParse(opts: RevParseListQuery & ExecOpts): Promise<string[]>;
3374
+ revParse(opts: {
3375
+ showObjectFormat: true | 'storage' | 'input' | 'output';
3376
+ } & ExecOpts): Promise<string>;
3377
+ revParse(opts: {
3378
+ showRefFormat: true;
3379
+ } & ExecOpts): Promise<string>;
3380
+ revParse(opts: {
3381
+ localEnvVars: true;
3382
+ } & ExecOpts): Promise<string[]>;
3383
+ /**
3384
+ * Count the number of commits reachable from a ref
3385
+ *
3386
+ * Wraps: `git rev-list --count`
3387
+ *
3388
+ * @example
3389
+ * ```typescript
3390
+ * const count = await repo.revListCount('HEAD');
3391
+ * const featureCommits = await repo.revListCount('main..feature');
3392
+ * ```
3393
+ */
3394
+ revListCount(ref?: string, opts?: ExecOpts): Promise<number>;
3395
+ /**
3396
+ * Read or modify symbolic refs
3397
+ *
3398
+ * Wraps: `git symbolic-ref`
3399
+ *
3400
+ * Without newRef: reads the symbolic ref (e.g., get what HEAD points to)
3401
+ * With newRef: sets the symbolic ref to point to newRef
3402
+ *
3403
+ * @example
3404
+ * ```typescript
3405
+ * // Read what HEAD points to
3406
+ * const branch = await repo.symbolicRef('HEAD');
3407
+ *
3408
+ * // Set HEAD to point to a branch
3409
+ * await repo.symbolicRef('HEAD', 'refs/heads/main');
3410
+ * ```
3411
+ */
3412
+ symbolicRef(name: string, newRef?: string, opts?: ExecOpts): Promise<string | undefined>;
3413
+ /**
3414
+ * Git submodule operations
3415
+ *
3416
+ * Wraps: `git submodule *` commands
3417
+ */
3418
+ submodule: SubmoduleOperations;
3419
+ /**
3420
+ * Git remote operations
3421
+ *
3422
+ * Wraps: `git remote *` commands
3423
+ */
3424
+ remote: RemoteOperations;
3425
+ /**
3426
+ * Git config operations (repository-level)
3427
+ *
3428
+ * Wraps: `git config` (without --global)
3429
+ */
3430
+ config: ConfigOperations;
3431
+ }
3432
+ /**
3433
+ * Bare repository (no working directory)
3434
+ *
3435
+ * A bare repository contains only the Git data without a working tree.
3436
+ * Typically used for shared/server repositories.
3437
+ */
3438
+ interface BareRepo extends RepoBase {
3439
+ /** Path to the git directory */
3440
+ readonly gitDir: string;
3441
+ /**
3442
+ * Fetch from remote
3443
+ *
3444
+ * Wraps: `git fetch`
3445
+ */
3446
+ fetch(opts?: FetchOpts & ExecOpts): Promise<void>;
3447
+ /**
3448
+ * Push to remote
3449
+ *
3450
+ * Wraps: `git push`
3451
+ */
3452
+ push(opts?: PushOpts & ExecOpts): Promise<void>;
3453
+ /**
3454
+ * Remote operations
3455
+ *
3456
+ * Wraps: `git remote` subcommands
3457
+ */
3458
+ remote: RemoteOperations;
3459
+ /**
3460
+ * Config operations (repository-level)
3461
+ *
3462
+ * Wraps: `git config` subcommands
3463
+ */
3464
+ config: ConfigOperations;
3465
+ /**
3466
+ * Parse revision specification and return information about the repository
3467
+ *
3468
+ * Wraps: `git rev-parse`
3469
+ *
3470
+ * @example
3471
+ * ```typescript
3472
+ * const sha = await repo.revParse('HEAD');
3473
+ * const gitDir = await repo.revParse({ gitDir: true });
3474
+ * const isShallow = await repo.revParse({ isShallowRepository: true });
3475
+ * ```
3476
+ */
3477
+ revParse(ref: string, opts?: RevParseRefOpts & ExecOpts): Promise<string>;
3478
+ revParse(opts: RevParsePathQuery & RevParsePathOpts & ExecOpts): Promise<string>;
3479
+ revParse(opts: RevParseBooleanQuery & ExecOpts): Promise<boolean>;
3480
+ revParse(opts: RevParseListQuery & ExecOpts): Promise<string[]>;
3481
+ revParse(opts: {
3482
+ showObjectFormat: true | 'storage' | 'input' | 'output';
3483
+ } & ExecOpts): Promise<string>;
3484
+ revParse(opts: {
3485
+ showRefFormat: true;
3486
+ } & ExecOpts): Promise<string>;
3487
+ revParse(opts: {
3488
+ localEnvVars: true;
3489
+ } & ExecOpts): Promise<string[]>;
3490
+ }
3491
+
3492
+ /**
3493
+ * Core Git interface - repository-agnostic operations
3494
+ */
3495
+
3496
+ /**
3497
+ * Options for git clone
3498
+ */
3499
+ type CloneOpts = {
3500
+ bare?: boolean;
3501
+ depth?: number;
3502
+ branch?: string;
3503
+ singleBranch?: boolean;
3504
+ mirror?: boolean;
3505
+ noCheckout?: boolean;
3506
+ recurseSubmodules?: boolean;
3507
+ /** Store .git directory at specified path instead of inside the repository */
3508
+ separateGitDir?: string;
3509
+ /**
3510
+ * Whether to clean up the target directory if the operation is aborted.
3511
+ * @default true
3512
+ */
3513
+ cleanupOnAbort?: boolean;
3514
+ /** Be more verbose */
3515
+ verbose?: boolean;
3516
+ /** Operate quietly (suppress progress reporting) */
3517
+ quiet?: boolean;
3518
+ /** Reject cloning a shallow repository */
3519
+ rejectShallow?: boolean;
3520
+ /** Clone from a local repository (use hard links) */
3521
+ local?: boolean;
3522
+ /** Don't use hard links for local clone */
3523
+ noHardlinks?: boolean;
3524
+ /** Share objects with a reference repository */
3525
+ shared?: boolean;
3526
+ /** Number of submodules to clone in parallel */
3527
+ jobs?: number;
3528
+ /** Directory with templates for the new repository */
3529
+ template?: string;
3530
+ /** Reference repository for object sharing */
3531
+ reference?: string;
3532
+ /** Reference repository if available (no error if not) */
3533
+ referenceIfAble?: string;
3534
+ /** Disconnect from reference repository after clone */
3535
+ dissociate?: boolean;
3536
+ /** Name of the remote (default: origin) */
3537
+ origin?: string;
3538
+ /** Create a shallow clone with commits since the specified date */
3539
+ shallowSince?: string | Date;
3540
+ /** Create a shallow clone excluding commits reachable from specified revision */
3541
+ shallowExclude?: string | string[];
3542
+ /** Don't clone any tags, and make later fetches not follow them */
3543
+ noTags?: boolean;
3544
+ /** Also clone submodules shallowly */
3545
+ shallowSubmodules?: boolean;
3546
+ /** Set config options for the new repository */
3547
+ config?: Record<string, string>;
3548
+ /** Use IPv4 addresses only */
3549
+ ipv4?: boolean;
3550
+ /** Use IPv6 addresses only */
3551
+ ipv6?: boolean;
3552
+ /** A partial clone filter specification (e.g., 'blob:none') */
3553
+ filter?: string;
3554
+ /** Also apply the partial clone filter to submodules */
3555
+ alsoFilterSubmodules?: boolean;
3556
+ /** Clone submodules from their remote tracking branch */
3557
+ remoteSubmodules?: boolean;
3558
+ /** Initialize sparse-checkout (clone only root files initially) */
3559
+ sparse?: boolean;
3560
+ };
3561
+ /**
3562
+ * Options for git init
3563
+ */
3564
+ type InitOpts = {
3565
+ bare?: boolean;
3566
+ initialBranch?: string;
3567
+ /** Store .git directory at specified path instead of inside the repository */
3568
+ separateGitDir?: string;
3569
+ /**
3570
+ * Whether to clean up the target directory if the operation is aborted.
3571
+ * @default true
3572
+ */
3573
+ cleanupOnAbort?: boolean;
3574
+ /** Directory with templates for the new repository */
3575
+ template?: string;
3576
+ /**
3577
+ * Set repository sharing level
3578
+ * - 'group': Group writable
3579
+ * - 'all'/'world'/'everybody': World readable
3580
+ * - number: Octal permissions
3581
+ */
3582
+ shared?: boolean | 'group' | 'all' | 'world' | 'everybody' | number;
3583
+ /** Operate quietly (suppress output) */
3584
+ quiet?: boolean;
3585
+ /** Specify the hash algorithm to use (sha1 or sha256) */
3586
+ objectFormat?: 'sha1' | 'sha256';
3587
+ };
3588
+ /**
3589
+ * Options for git ls-remote
3590
+ */
3591
+ type LsRemoteOpts = {
3592
+ /** Limit to refs/heads (branches) */
3593
+ heads?: boolean;
3594
+ /** Limit to refs/tags */
3595
+ tags?: boolean;
3596
+ /** Show only actual refs (not peeled tags) */
3597
+ refs?: boolean;
3598
+ /** Show remote URL instead of listing refs */
3599
+ getUrl?: boolean;
3600
+ /** Sort refs by the given key (e.g., 'version:refname') */
3601
+ sort?: string;
3602
+ /** Show symbolic refs in addition to object refs */
3603
+ symref?: boolean;
3604
+ };
3605
+ /**
3606
+ * Result from git ls-remote
3607
+ */
3608
+ type LsRemoteResult = {
3609
+ refs: Array<{
3610
+ hash: string;
3611
+ name: string;
3612
+ }>;
3613
+ };
3614
+ /**
3615
+ * Options for global LFS install
3616
+ *
3617
+ * Used with `git.lfs.install()` for user-level (~/.gitconfig) or
3618
+ * system-level (/etc/gitconfig) LFS configuration.
3619
+ *
3620
+ * @remarks
3621
+ * Internally runs `git lfs install` without `--local` flag.
3622
+ * For repository-level installation, use `repo.lfs.install()` instead.
3623
+ */
3624
+ type GlobalLfsInstallOpts = {
3625
+ /** Overwrite existing hooks */
3626
+ force?: boolean;
3627
+ /**
3628
+ * Install for all users (system-wide)
3629
+ *
3630
+ * @remarks
3631
+ * Internally adds `--system` flag to install to /etc/gitconfig
3632
+ * instead of ~/.gitconfig. Requires appropriate permissions.
3633
+ */
3634
+ system?: boolean;
3635
+ /** Skip smudge filter (don't download during checkout) */
3636
+ skipSmudge?: boolean;
3637
+ /** Skip repository setup (only install filters) */
3638
+ skipRepo?: boolean;
3639
+ /** Print commands instead of executing */
3640
+ manual?: boolean;
3641
+ };
3642
+ /**
3643
+ * Options for global LFS uninstall
3644
+ *
3645
+ * Used with `git.lfs.uninstall()` for user-level or system-level
3646
+ * LFS configuration removal.
3647
+ *
3648
+ * @remarks
3649
+ * Internally runs `git lfs uninstall` without `--local` flag.
3650
+ * For repository-level uninstallation, use `repo.lfs.uninstall()` instead.
3651
+ */
3652
+ type GlobalLfsUninstallOpts = {
3653
+ /**
3654
+ * Uninstall for all users (system-wide)
3655
+ *
3656
+ * @remarks
3657
+ * Internally adds `--system` flag to modify /etc/gitconfig
3658
+ * instead of ~/.gitconfig. Requires appropriate permissions.
3659
+ */
3660
+ system?: boolean;
3661
+ /** Skip repository cleanup */
3662
+ skipRepo?: boolean;
3663
+ };
3664
+ /**
3665
+ * Global LFS operations
3666
+ *
3667
+ * Wraps: `git lfs` subcommands for user-level configuration
3668
+ *
3669
+ * Operates on ~/.gitconfig (user-level) or /etc/gitconfig (system-level).
3670
+ * For repository-level LFS operations, use repo.lfs instead.
3671
+ */
3672
+ interface GlobalLfsOperations {
3673
+ /**
3674
+ * Install Git LFS hooks globally
3675
+ *
3676
+ * Wraps: `git lfs install`
3677
+ *
3678
+ * Sets up the clean and smudge filters under the name "lfs" in the
3679
+ * global Git config (~/.gitconfig) or system config (/etc/gitconfig).
3680
+ *
3681
+ * @example
3682
+ * ```typescript
3683
+ * // Install globally (to ~/.gitconfig)
3684
+ * await git.lfs.install();
3685
+ *
3686
+ * // Install system-wide (to /etc/gitconfig)
3687
+ * await git.lfs.install({ system: true });
3688
+ *
3689
+ * // Install with skip-smudge (manual LFS pull required)
3690
+ * await git.lfs.install({ skipSmudge: true });
3691
+ * ```
3692
+ */
3693
+ install(opts?: GlobalLfsInstallOpts & ExecOpts): Promise<void>;
3694
+ /**
3695
+ * Uninstall Git LFS hooks globally
3696
+ *
3697
+ * Wraps: `git lfs uninstall`
3698
+ *
3699
+ * Removes the clean and smudge filters from global or system config.
3700
+ *
3701
+ * @example
3702
+ * ```typescript
3703
+ * // Uninstall from global config
3704
+ * await git.lfs.uninstall();
3705
+ *
3706
+ * // Uninstall from system config
3707
+ * await git.lfs.uninstall({ system: true });
3708
+ * ```
3709
+ */
3710
+ uninstall(opts?: GlobalLfsUninstallOpts & ExecOpts): Promise<void>;
3711
+ /**
3712
+ * Get Git LFS version
3713
+ *
3714
+ * Wraps: `git lfs version`
3715
+ *
3716
+ * @returns LFS version string (e.g., "git-lfs/3.4.0")
3717
+ */
3718
+ version(opts?: ExecOpts): Promise<string>;
3719
+ }
3720
+ /**
3721
+ * Options for global config list
3722
+ */
3723
+ type GlobalConfigListOpts = {
3724
+ /** Show origin of each value */
3725
+ showOrigin?: boolean;
3726
+ /** Show scope of each value */
3727
+ showScope?: boolean;
3728
+ };
3729
+ /**
3730
+ * Global config operations
3731
+ *
3732
+ * Wraps: `git config --global` subcommands
3733
+ *
3734
+ * Operates on ~/.gitconfig (user-level configuration).
3735
+ * Uses the same typed ConfigSchema as repository-level config.
3736
+ */
3737
+ interface GlobalConfigOperations {
3738
+ /**
3739
+ * Get a typed global config value
3740
+ *
3741
+ * Wraps: `git config --global --get <key>`
3742
+ *
3743
+ * @returns Config value or undefined if not set
3744
+ */
3745
+ get<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<ConfigSchema[K] | undefined>;
3746
+ /**
3747
+ * Get all values for a typed multi-valued global config key
3748
+ *
3749
+ * Wraps: `git config --global --get-all <key>`
3750
+ */
3751
+ getAll<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<ConfigSchema[K][]>;
3752
+ /**
3753
+ * Set a typed global config value
3754
+ *
3755
+ * Wraps: `git config --global <key> <value>`
3756
+ */
3757
+ set<K extends ConfigKey>(key: K, value: ConfigSchema[K], opts?: ExecOpts): Promise<void>;
3758
+ /**
3759
+ * Add a value to a typed multi-valued global config key
3760
+ *
3761
+ * Wraps: `git config --global --add <key> <value>`
3762
+ */
3763
+ add<K extends ConfigKey>(key: K, value: ConfigSchema[K], opts?: ExecOpts): Promise<void>;
3764
+ /**
3765
+ * Unset a typed global config value
3766
+ *
3767
+ * Wraps: `git config --global --unset <key>`
3768
+ */
3769
+ unset<K extends ConfigKey>(key: K, opts?: ExecOpts): Promise<void>;
3770
+ /**
3771
+ * Get a raw global config value (for arbitrary keys)
3772
+ *
3773
+ * Wraps: `git config --global --get <key>`
3774
+ *
3775
+ * @returns Config value or undefined if not set
3776
+ */
3777
+ getRaw(key: string, opts?: ConfigGetOpts & ExecOpts): Promise<string | string[] | undefined>;
3778
+ /**
3779
+ * Set a raw global config value (for arbitrary keys)
3780
+ *
3781
+ * Wraps: `git config --global <key> <value>`
3782
+ */
3783
+ setRaw(key: string, value: string, opts?: ConfigSetOpts & ExecOpts): Promise<void>;
3784
+ /**
3785
+ * Unset a raw global config value (for arbitrary keys)
3786
+ *
3787
+ * Wraps: `git config --global --unset <key>`
3788
+ */
3789
+ unsetRaw(key: string, opts?: ExecOpts): Promise<void>;
3790
+ /**
3791
+ * List all global config values
3792
+ *
3793
+ * Wraps: `git config --global --list`
3794
+ */
3795
+ list(opts?: GlobalConfigListOpts & ExecOpts): Promise<ConfigEntry[]>;
3796
+ }
3797
+ /**
3798
+ * Main Git interface for repository-agnostic operations
3799
+ *
3800
+ * Provides type-safe wrappers for Git commands that don't require a repository context.
3801
+ * Each method corresponds to a specific Git CLI command.
3802
+ */
3803
+ interface Git {
3804
+ /**
3805
+ * Open an existing worktree repository
3806
+ *
3807
+ * This is the most common use case. Throws GitError if the repository is bare.
3808
+ *
3809
+ * @param path - Path to the repository working directory
3810
+ * @param opts - Environment isolation and credential options
3811
+ * @returns WorktreeRepo
3812
+ * @throws GitError with kind 'NotWorktreeRepo' if the repository is bare
3813
+ */
3814
+ open(path: string, opts?: GitOpenOptions): Promise<WorktreeRepo>;
3815
+ /**
3816
+ * Open an existing bare repository
3817
+ *
3818
+ * Throws GitError if the repository is not bare.
3819
+ *
3820
+ * @param path - Path to the bare repository (git-dir)
3821
+ * @param opts - Environment isolation and credential options
3822
+ * @returns BareRepo
3823
+ * @throws GitError with kind 'NotBareRepo' if the repository is not bare
3824
+ */
3825
+ openBare(path: string, opts?: GitOpenOptions): Promise<BareRepo>;
3826
+ /**
3827
+ * Open an existing repository without type guarantee
3828
+ *
3829
+ * Returns either WorktreeRepo or BareRepo depending on the repository type.
3830
+ * Use this when you don't know the repository type at compile time.
3831
+ * You can use `isWorktree()` or `isBare()` methods for runtime type checking.
3832
+ *
3833
+ * @param path - Path to the repository (workdir or git-dir)
3834
+ * @param opts - Environment isolation and credential options
3835
+ * @returns WorktreeRepo or BareRepo depending on repository type
3836
+ *
3837
+ * @example
3838
+ * ```typescript
3839
+ * const repo = await git.openRaw('/path/to/repo');
3840
+ * if (await repo.isWorktree()) {
3841
+ * // repo is WorktreeRepo at runtime
3842
+ * const status = await (repo as WorktreeRepo).status();
3843
+ * } else if (await repo.isBare()) {
3844
+ * // repo is BareRepo at runtime
3845
+ * await (repo as BareRepo).fetch({ remote: 'origin' });
3846
+ * }
3847
+ * ```
3848
+ */
3849
+ openRaw(path: string, opts?: GitOpenOptions): Promise<WorktreeRepo | BareRepo>;
3850
+ /**
3851
+ * Clone a repository
3852
+ *
3853
+ * Wraps: `git clone <url> <path>`
3854
+ *
3855
+ * The return type depends on the `bare` or `mirror` option:
3856
+ * - `{ bare: true }` or `{ mirror: true }` → `BareRepo`
3857
+ * - Otherwise → `WorktreeRepo`
3858
+ */
3859
+ clone(url: string, path: string, opts: CloneOpts & {
3860
+ bare: true;
3861
+ } & ExecOpts): Promise<BareRepo>;
3862
+ clone(url: string, path: string, opts: CloneOpts & {
3863
+ mirror: true;
3864
+ } & ExecOpts): Promise<BareRepo>;
3865
+ clone(url: string, path: string, opts?: CloneOpts & ExecOpts): Promise<WorktreeRepo>;
3866
+ /**
3867
+ * Initialize a new repository
3868
+ *
3869
+ * Wraps: `git init <path>`
3870
+ *
3871
+ * The return type depends on the `bare` option:
3872
+ * - `{ bare: true }` → `BareRepo`
3873
+ * - Otherwise → `WorktreeRepo`
3874
+ */
3875
+ init(path: string, opts: InitOpts & {
3876
+ bare: true;
3877
+ } & ExecOpts): Promise<BareRepo>;
3878
+ init(path: string, opts?: InitOpts & ExecOpts): Promise<WorktreeRepo>;
3879
+ /**
3880
+ * List references in a remote repository
3881
+ *
3882
+ * Wraps: `git ls-remote <url>`
3883
+ */
3884
+ lsRemote(url: string, opts?: LsRemoteOpts & ExecOpts): Promise<LsRemoteResult>;
3885
+ /**
3886
+ * Get git version
3887
+ *
3888
+ * Wraps: `git --version`
3889
+ */
3890
+ version(opts?: ExecOpts): Promise<string>;
3891
+ /**
3892
+ * Execute a raw git command (repository-agnostic)
3893
+ *
3894
+ * Wraps: `git <argv...>`
3895
+ */
3896
+ raw(argv: string[], opts?: ExecOpts): Promise<RawResult>;
3897
+ /**
3898
+ * Global config operations
3899
+ *
3900
+ * Wraps: `git config --global` subcommands
3901
+ *
3902
+ * Operates on ~/.gitconfig (user-level configuration).
3903
+ * For repository-level config, use repo.config instead.
3904
+ */
3905
+ config: GlobalConfigOperations;
3906
+ /**
3907
+ * Global LFS operations
3908
+ *
3909
+ * Wraps: `git lfs` subcommands for user-level configuration
3910
+ *
3911
+ * Operates on ~/.gitconfig (user-level) or /etc/gitconfig (system-level).
3912
+ * For repository-level LFS operations, use repo.lfs instead.
3913
+ */
3914
+ lfs: GlobalLfsOperations;
3915
+ }
3916
+
3917
+ /**
3918
+ * CLI Runner - Core execution engine for Git commands
3919
+ *
3920
+ * This module provides:
3921
+ * - CliRunner: Executes Git commands with progress tracking and abort support
3922
+ * - Progress collection from stderr (Git and LFS)
3923
+ * - Error mapping from Git exit codes
3924
+ */
3925
+
3926
+ /**
3927
+ * Credential helper configuration
3928
+ */
3929
+ type CredentialHelperConfig = {
3930
+ /** Helper name (e.g., 'store', 'cache', 'manager-core', or custom name) */
3931
+ helper?: string;
3932
+ /** Path to custom helper binary */
3933
+ helperPath?: string;
3934
+ };
3935
+ /**
3936
+ * Options for CliRunner
3937
+ */
3938
+ type CliRunnerOptions = {
3939
+ /** Git binary path (default: 'git') */
3940
+ gitBinary?: string;
3941
+ /** Additional environment variables */
3942
+ env?: Record<string, string>;
3943
+ /** Directories to prepend to PATH */
3944
+ pathPrefix?: string[];
3945
+ /** Custom HOME directory for git config isolation */
3946
+ home?: string;
3947
+ /** Credential helper configuration */
3948
+ credential?: CredentialHelperConfig;
3949
+ };
3950
+ /**
3951
+ * CLI Runner for executing Git commands
3952
+ *
3953
+ * Handles:
3954
+ * - Command construction based on execution context
3955
+ * - Progress tracking from stderr (Git and LFS)
3956
+ * - Abort signal handling
3957
+ * - Error mapping
3958
+ */
3959
+ declare class CliRunner {
3960
+ private readonly exec;
3961
+ private readonly gitBinary;
3962
+ private readonly baseEnv;
3963
+ private readonly pathPrefix;
3964
+ private readonly home;
3965
+ private readonly credential;
3966
+ constructor(adapters: RuntimeAdapters, options?: CliRunnerOptions);
3967
+ /**
3968
+ * Create a new CliRunner with additional options merged
3969
+ *
3970
+ * Used to create a runner for a specific repository with custom environment
3971
+ */
3972
+ withOptions(options: CliRunnerOptions): CliRunner;
3973
+ /**
3974
+ * Build command argv based on execution context
3975
+ */
3976
+ private buildArgv;
3977
+ /**
3978
+ * Build the effective environment for command execution
3979
+ *
3980
+ * Applies home directory and PATH prefix overrides
3981
+ */
3982
+ private buildEnv;
3983
+ /**
3984
+ * Extract directory from a file path
3985
+ */
3986
+ private extractDirectory;
3987
+ /**
3988
+ * Run a Git command
3989
+ */
3990
+ run(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
3991
+ /**
3992
+ * Map Git result to GitError if needed
3993
+ */
3994
+ mapError(result: RawResult, context: ExecutionContext, argv: string[]): GitError | null;
3995
+ /**
3996
+ * Classify error type based on stderr content
3997
+ */
3998
+ private classifyError;
3999
+ /**
4000
+ * Extract user-friendly error message from stderr
4001
+ */
4002
+ private extractErrorMessage;
4003
+ /**
4004
+ * Run a command and throw on error
4005
+ */
4006
+ runOrThrow(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
4007
+ }
4008
+
4009
+ /**
4010
+ * Git implementation - repository-agnostic operations
4011
+ */
4012
+
4013
+ /**
4014
+ * Default minimum supported Git version.
4015
+ *
4016
+ * This is the minimum version required when `useLegacyVersion` is false (the default).
4017
+ * Use `useLegacyVersion: true` to allow older Git versions (2.25.0+).
4018
+ */
4019
+ declare const MIN_GIT_VERSION = "2.30.0";
4020
+ /**
4021
+ * Legacy minimum Git version
4022
+ *
4023
+ * When `useLegacyVersion: true` is set, this version is used as the minimum.
4024
+ * Git 2.25.0 is the default version on Ubuntu 20.04 LTS.
4025
+ */
4026
+ declare const LEGACY_GIT_VERSION = "2.25.0";
4027
+ /**
4028
+ * Options for creating a Git instance
4029
+ */
4030
+ type CreateGitOptions = CliRunnerOptions & {
4031
+ /** Runtime adapters (exec, fs) */
4032
+ adapters: RuntimeAdapters;
4033
+ /**
4034
+ * Controls whether to perform a Git version check during initialization.
4035
+ * When true, skips the Git version check. When false (default), throws
4036
+ * GitError if Git version is below the minimum required version.
4037
+ * @default false
4038
+ */
4039
+ skipVersionCheck?: boolean;
4040
+ /**
4041
+ * Allow legacy Git versions (2.25.0+) instead of requiring 2.30.0+.
4042
+ *
4043
+ * Use this for environments with older Git installations such as
4044
+ * Ubuntu 20.04 LTS which ships with Git 2.25.1 by default.
4045
+ *
4046
+ * @default false
4047
+ */
4048
+ useLegacyVersion?: boolean;
4049
+ };
4050
+ /**
4051
+ * Create a new Git instance (synchronous, no version check)
4052
+ *
4053
+ * @param options - Creation options including runtime adapters
4054
+ * @returns Git instance
4055
+ * @deprecated Use createGit instead for version checking
4056
+ */
4057
+ declare function createGitSync(options: CreateGitOptions): Git;
4058
+ /**
4059
+ * Create a new Git instance with optional version check
4060
+ *
4061
+ * @param options - Creation options including runtime adapters
4062
+ * @returns Git instance
4063
+ * @throws GitError with kind 'UnsupportedGitVersion' if Git version is below minimum
4064
+ */
4065
+ declare function createGit(options: CreateGitOptions): Promise<Git>;
4066
+
4067
+ /**
4068
+ * Node.js ExecAdapter implementation
4069
+ */
4070
+
4071
+ declare class NodeExecAdapter implements ExecAdapter {
4072
+ getCapabilities(): Capabilities;
4073
+ spawn(options: SpawnOptions, handlers?: StreamHandler): Promise<SpawnResult>;
4074
+ spawnStreaming(options: SpawnOptions): SpawnHandle;
4075
+ }
4076
+
4077
+ /**
4078
+ * Node.js FsAdapter implementation
4079
+ */
4080
+
4081
+ declare class NodeFsAdapter implements FsAdapter {
4082
+ createTempFile(prefix?: string): Promise<string>;
4083
+ tail(options: TailOptions): Promise<void>;
4084
+ deleteFile(filePath: string): Promise<void>;
4085
+ deleteDirectory(dirPath: string): Promise<void>;
4086
+ exists(filePath: string): Promise<boolean>;
4087
+ readFile(filePath: string): Promise<string>;
4088
+ writeFile(filePath: string, contents: string): Promise<void>;
4089
+ tailStreaming(filePath: string, options?: {
4090
+ signal?: AbortSignal;
4091
+ pollInterval?: number;
4092
+ }): TailHandle;
4093
+ }
4094
+
4095
+ /**
4096
+ * Node.js adapter exports
4097
+ */
4098
+
4099
+ /**
4100
+ * Create Node.js runtime adapters
4101
+ */
4102
+ declare function createNodeAdapters(): RuntimeAdapters;
4103
+ /**
4104
+ * Options for creating a TypeGit instance (Node.js)
4105
+ * Excludes adapters as they are automatically configured
4106
+ */
4107
+ type TypeGitOptions = Omit<CreateGitOptions, 'adapters'>;
4108
+ /**
4109
+ * Pre-configured Git client for Node.js
4110
+ *
4111
+ * This is a convenience class that automatically configures Node.js adapters.
4112
+ *
4113
+ * @example
4114
+ * ```typescript
4115
+ * import { TypeGit } from 'type-git/node';
4116
+ *
4117
+ * // Recommended: Use create() for version check
4118
+ * const git = await TypeGit.create();
4119
+ *
4120
+ * // Skip version check (not recommended)
4121
+ * const git = await TypeGit.create({ skipVersionCheck: true });
4122
+ *
4123
+ * // Legacy: constructor (no version check, deprecated)
4124
+ * const git = new TypeGit();
4125
+ *
4126
+ * const repo = await git.open('/path/to/repo');
4127
+ * ```
4128
+ */
4129
+ declare class TypeGit {
4130
+ private readonly git;
4131
+ /**
4132
+ * Create a TypeGit instance with Git version check
4133
+ *
4134
+ * @param createOpts - Options including skipVersionCheck
4135
+ * @returns TypeGit instance
4136
+ * @throws GitError with kind 'UnsupportedGitVersion' if Git version is below minimum
4137
+ */
4138
+ static create(createOpts?: TypeGitOptions): Promise<TypeGit>;
4139
+ /**
4140
+ * @deprecated Use TypeGit.create() instead for version checking
4141
+ */
4142
+ constructor(constructorOpts?: TypeGitOptions);
4143
+ /** @internal */
4144
+ constructor(existingGit: Git);
4145
+ /**
4146
+ * Open an existing worktree repository
4147
+ *
4148
+ * This is the most common use case. Throws GitError if the repository is bare.
4149
+ *
4150
+ * @throws GitError with kind 'NotWorktreeRepo' if the repository is bare
4151
+ */
4152
+ get open(): (path: string, opts?: GitOpenOptions) => Promise<WorktreeRepo>;
4153
+ /**
4154
+ * Open an existing bare repository
4155
+ *
4156
+ * Throws GitError if the repository is not bare.
4157
+ *
4158
+ * @throws GitError with kind 'NotBareRepo' if the repository is not bare
4159
+ */
4160
+ get openBare(): (path: string, opts?: GitOpenOptions) => Promise<BareRepo>;
4161
+ /**
4162
+ * Open an existing repository without type guarantee
4163
+ *
4164
+ * Returns either WorktreeRepo or BareRepo depending on the repository type.
4165
+ * Use this when you don't know the repository type at compile time.
4166
+ */
4167
+ get openRaw(): (path: string, opts?: GitOpenOptions) => Promise<WorktreeRepo | BareRepo>;
4168
+ /**
4169
+ * Clone a repository
4170
+ *
4171
+ * The return type depends on the `bare` or `mirror` option:
4172
+ * - `{ bare: true }` or `{ mirror: true }` → `BareRepo`
4173
+ * - Otherwise → `WorktreeRepo`
4174
+ */
4175
+ clone(url: string, path: string, opts: CloneOpts & {
4176
+ bare: true;
4177
+ } & ExecOpts): Promise<BareRepo>;
4178
+ clone(url: string, path: string, opts: CloneOpts & {
4179
+ mirror: true;
4180
+ } & ExecOpts): Promise<BareRepo>;
4181
+ clone(url: string, path: string, opts?: CloneOpts & ExecOpts): Promise<WorktreeRepo>;
4182
+ /**
4183
+ * Initialize a new repository
4184
+ *
4185
+ * The return type depends on the `bare` option:
4186
+ * - `{ bare: true }` → `BareRepo`
4187
+ * - Otherwise → `WorktreeRepo`
4188
+ */
4189
+ init(path: string, opts: InitOpts & {
4190
+ bare: true;
4191
+ } & ExecOpts): Promise<BareRepo>;
4192
+ init(path: string, opts?: InitOpts & ExecOpts): Promise<WorktreeRepo>;
4193
+ /**
4194
+ * List references in a remote repository
4195
+ */
4196
+ get lsRemote(): (url: string, opts?: LsRemoteOpts & ExecOpts) => Promise<LsRemoteResult>;
4197
+ /**
4198
+ * Get git version
4199
+ */
4200
+ get version(): (opts?: ExecOpts) => Promise<string>;
4201
+ /**
4202
+ * Execute a raw git command (repository-agnostic)
4203
+ */
4204
+ get raw(): (argv: string[], opts?: ExecOpts) => Promise<RawResult>;
4205
+ /**
4206
+ * Global config operations
4207
+ *
4208
+ * Operates on ~/.gitconfig (user-level configuration).
4209
+ * For repository-level config, use repo.config instead.
4210
+ */
4211
+ get config(): GlobalConfigOperations;
4212
+ /**
4213
+ * Global LFS operations
4214
+ *
4215
+ * Operates on ~/.gitconfig (user-level) or /etc/gitconfig (system-level).
4216
+ * For repository-level LFS operations, use repo.lfs instead.
4217
+ *
4218
+ * @example
4219
+ * ```typescript
4220
+ * // Install LFS globally
4221
+ * await git.lfs.install();
4222
+ *
4223
+ * // Install system-wide
4224
+ * await git.lfs.install({ system: true });
4225
+ *
4226
+ * // Get LFS version
4227
+ * const version = await git.lfs.version();
4228
+ * ```
4229
+ */
4230
+ get lfs(): GlobalLfsOperations;
4231
+ }
4232
+
4233
+ export { type BranchOpts as $, type GlobalLfsInstallOpts as A, type GlobalLfsUninstallOpts as B, type CreateGitOptions as C, type GlobalLfsOperations as D, type GlobalConfigListOpts as E, type GlobalConfigOperations as F, GIT_LOG_FORMAT as G, type Git as H, type InitOpts as I, type RepoLsRemoteOpts as J, type RepoLsRemoteResult as K, LEGACY_GIT_VERSION as L, MIN_GIT_VERSION as M, type LsTreeEntry as N, NodeExecAdapter, NodeFsAdapter, type LsTreeOpts as O, type ParsedCommit as P, type StatusPorcelain as Q, type RepoBase as R, type StatusEntry as S, type StatusOpts as T, TypeGit, type TypeGitOptions, type Commit as U, type LogOpts as V, type FetchOpts as W, type ForceWithLeaseOpts as X, type PushOpts as Y, type AddOpts as Z, type BranchInfo as _, createGitSync as a, type LfsMigrateInfoOpts as a$, type BranchCreateOpts as a0, type BranchDeleteOpts as a1, type CheckoutBranchOpts as a2, type CheckoutPathOpts as a3, type CheckoutOpts as a4, type CommitOpts as a5, type CommitResult as a6, type DiffOpts as a7, type DiffEntry as a8, type DiffResult as a9, type RevParsePathOpts as aA, type SubmoduleOpts as aB, type SubmoduleAddOpts as aC, type SubmoduleDeinitOpts as aD, type SubmoduleStatusOpts as aE, type SubmoduleSummaryOpts as aF, type SubmoduleForeachOpts as aG, type SubmoduleSyncOpts as aH, type SubmoduleSetBranchOpts as aI, type SubmoduleInfo as aJ, type LfsStatus as aK, type LfsPullOpts as aL, type LfsPushOpts as aM, type LfsStatusOpts as aN, type LfsPruneOpts as aO, type LfsFetchOpts as aP, type RepoLfsInstallOpts as aQ, type RepoLfsUninstallOpts as aR, type LfsFileEntry as aS, type LfsLsFilesOpts as aT, type LfsTrackEntry as aU, type LfsTrackOpts as aV, type LfsLockEntry as aW, type LfsLockOpts as aX, type LfsUnlockOpts as aY, type LfsLocksOpts as aZ, type LfsCheckoutOpts as a_, type MergeOpts as aa, type MergeResult as ab, type PullOpts as ac, type ResetOpts as ad, type RmOpts as ae, type StashEntry as af, type StashPushOpts as ag, type StashApplyOpts as ah, type SwitchOpts as ai, type TagInfo as aj, type TagListOpts as ak, type TagCreateOpts as al, type CherryPickOpts as am, type CleanOpts as an, type MvOpts as ao, type RebaseOpts as ap, type RestoreOpts as aq, type RevertOpts as ar, type ShowOpts as as, type RevParsePathQuery as at, type RevParseBooleanQuery as au, type RevParseListOpts as av, type RevParseListQuery as aw, type RevParseRefOpts as ax, type RevParseOtherQuery as ay, type RevParsePathFormat as az, type GitProgressInfo as b, type LfsMigrateImportOpts as b0, type LfsMigrateExportOpts as b1, type LfsEnvInfo as b2, type LfsPreUploadOpts as b3, type LfsPreUploadResult as b4, type LfsPreDownloadOpts as b5, type LfsPreDownloadResult as b6, type Worktree as b7, type WorktreeAddOpts as b8, type WorktreeRemoveOpts as b9, type SubmoduleOperations as bA, type WorktreeRepo as bB, type BareRepo as bC, type WorktreePruneOpts as ba, type WorktreeMoveOpts as bb, type WorktreeRepairOpts as bc, type WorktreeLockOpts as bd, type WorktreeOperations as be, type LfsOperations as bf, type LfsExtraOperations as bg, type BranchOperations as bh, type StashOperations as bi, type TagOperations as bj, type RemoteInfo as bk, type RemoteAddOpts as bl, type RemoteSetHeadOpts as bm, type RemoteShowOpts as bn, type RemotePruneOpts as bo, type RemoteUpdateOpts as bp, type RemoteSetBranchesOpts as bq, type RemoteUrlOpts as br, type RemoteOperations as bs, type ConfigEntry as bt, type ConfigGetOpts as bu, type ConfigSetOpts as bv, type ConfigListOpts as bw, type ConfigSchema as bx, type ConfigKey as by, type ConfigOperations as bz, createGit as c, createNodeAdapters, detectErrorCategory as d, type LfsProgressInfo as e, type LsRemoteRef as f, type LsTreeObjectType$1 as g, type ParsedLsTreeEntry as h, type ParsedWorktree as i, type PorcelainV2Entry as j, parseGitProgress as k, parseJson as l, parseKeyValue as m, parseLfsProgress as n, parseLines as o, parseGitLog as p, parseLsRemote as q, parseLsTree as r, parsePorcelainV2 as s, parseRecords as t, parseWorktreeList as u, CliRunner as v, type CliRunnerOptions as w, type CloneOpts as x, type LsRemoteOpts as y, type LsRemoteResult as z };