@hyperfrontend/versioning/git/operations

operations

Typed wrappers around git shell commands — log, tag, commit, staging, status, and diff — returning structured data instead of raw text.

The commit family (commit, amendCommit, amendCommitNoEdit, createEmptyCommit) drives git commit with safe argument escaping (escapeFilePath, escapeAuthor). The tag family covers creation (createTag), querying (getTags), and lookup (getTag). Diff helpers (getChangedFilesBetween, getChangedFilesBetweenWithStatus, getCommitWithFiles) return typed FileChange[] and GitCommitWithFiles shapes. Status (getStatus, returning RepositoryStatus with FileStatusEntry[]) and staging (stage, discardChanges) round out the everyday git surface. GitOperationState captures retry/idempotency reasons for steps that can be safely re-run.

API Reference§

ƒ Functions

§function

amendCommit(message: string, options: Omit<CreateCommitOptions, "amend">): GitCommit

Amends the last commit with new message.
Parameters
NameTypeDescription
§message
stringThe new commit message to use
§options
Omit<CreateCommitOptions, "amend">Configuration for the commit operation(default: {})
Returns
GitCommit
GitCommit object representing the amended commit
Example
Amend the last commit with a new message
const commit = amendCommit('feat: improved feature')
§function

amendCommitNoEdit(options: Omit<CreateCommitOptions, "amend" | "noEdit">): GitCommit

Amends the last commit without changing the message. Useful for adding staged changes to the previous commit.
Parameters
NameTypeDescription
§options
Omit<CreateCommitOptions, "amend" | "noEdit">Configuration for the commit operation(default: {})
Returns
GitCommit
GitCommit object representing the amended commit
Example
Add staged changes to last commit without changing message
stage(['extra-file.ts'])
amendCommitNoEdit() // adds staged files to last commit
§function

commit(message: string, options: CreateCommitOptions): GitCommit

Creates a new commit.
Parameters
NameTypeDescription
§message
stringCommit message (subject line)
§options
CreateCommitOptionsCreate options(default: {})
Returns
GitCommit
Created GitCommit
Example
Create a new commit
const commit = createCommit('feat: add new feature')
const commit = createCommit('fix: resolve bug', { body: 'Detailed description' })
§function

commitExists(hash: string, options: Pick<GitLogOptions, "cwd" | "timeout">): boolean

Checks if a commit exists in the repository.
Parameters
NameTypeDescription
§hash
stringCommit hash to check
§options
Pick<GitLogOptions, "cwd" | "timeout">Additional options(default: {})
Returns
boolean
True if commit exists
Example

Check if a commit exists in the repository

if (commitExists('abc123def')) {
  console.log('Commit found in repository')
}
§function

commitReachableFromHead(hash: string, options: Pick<GitLogOptions, "cwd" | "timeout">): boolean

Checks if a commit is reachable from HEAD (i.e., is an ancestor of HEAD).
A commit may exist in the repository but be orphaned (not in current branch history). This function verifies that the commit is actually in the history of the current HEAD.
Common use cases:
  • Verify an external commit reference before using it for range queries
  • Detect if history was rewritten (rebase/force push) after a reference was recorded
Parameters
NameTypeDescription
§hash
stringCommit hash to check
§options
Pick<GitLogOptions, "cwd" | "timeout">Additional options(default: {})
Returns
boolean
True if the commit is an ancestor of HEAD
Example
Check if commit is reachable from HEAD
if (commitReachableFromHead(baseCommit)) {
  // Safe to use for commit range queries
  const commits = getCommitsSince(baseCommit)
} else {
  // Commit not in current history, need fallback strategy
}
§function

createEmptyCommit(message: string, options: Omit<CreateCommitOptions, "allowEmpty">): GitCommit

Creates an empty commit (useful for CI triggers).
Parameters
NameTypeDescription
§message
stringText for the empty commit
§options
Omit<CreateCommitOptions, "allowEmpty">Configuration for the commit operation(default: {})
Returns
GitCommit
GitCommit object representing the new empty commit
Example
Create an empty commit for CI triggers
const commit = createEmptyCommit('chore: trigger CI')
§function

createTag(name: string, options: CreateTagOptions): GitTag

Creates a new tag.
Parameters
NameTypeDescription
§name
stringThe name for the new tag
§options
CreateTagOptionsConfiguration including optional message for annotated tags(default: {})
Returns
GitTag
Created GitTag
Example
Create lightweight and annotated tags
// Create lightweight tag
const tag = createTag('v1.0.0')

// Create annotated tag
const tag = createTag('v1.0.0', { message: 'Release v1.0.0' })
§function

deleteTag(name: string, options: GitTagOptions): boolean

Deletes a tag.
Parameters
NameTypeDescription
§name
stringThe tag name to delete
§options
GitTagOptionsConfiguration for the tag operation(default: {})
Returns
boolean
True if deleted
Example
Delete a tag by name
const deleted = deleteTag('v1.0.0')
§function

discardAllChanges(options: GitCommitOptions): boolean

Discards all uncommitted changes and unstages all files.
Combines discardChanges() + unstage(['.']) for complete working tree reset.
Warning: Destructive operation: discarded changes cannot be recovered.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the operation(default: {})
Returns
boolean
True if both operations succeeded
Example

Reset working directory to match HEAD

// Reset working directory to match HEAD
if (discardAllChanges()) {
  console.log('Working tree reset to HEAD')
}
§function

discardChanges(options: DiscardChangesOptions): boolean

Discards uncommitted changes to tracked files.
Uses git checkout -- <files> to restore files from HEAD. Returns true if successful, false otherwise (silent failure pattern).
Warning: Destructive operation: discarded changes cannot be recovered.
Parameters
NameTypeDescription
§options
DiscardChangesOptionsConfiguration including optional file list(default: {})
Returns
boolean
True if discard succeeded
Examples
Discard changes in tracked files
// Discard all changes
discardChanges()

// Discard specific files
discardChanges({ files: ['package.json', 'CHANGELOG.md'] })
Typical rollback pattern
// Typical rollback pattern
if (hasUnstagedChanges()) {
  discardChanges()
}
if (hasStagedChanges()) {
  unstage(['.'])
}
§function

escapeAuthor(author: string): string

Escapes an author string for safe use in git commands. Format: "Name <email>"
Parameters
NameTypeDescription
§author
stringAuthor to escape
Returns
string
Safe author string
Example

Escape an author string for git commit

const safeAuthor = escapeAuthor('John Doe <john@example.com>')
// => 'John Doe <john@example.com>'
§function

escapeFilePath(path: string): string

Escapes a file path for safe use in git commands.
Parameters
NameTypeDescription
§path
stringPath to escape
Returns
string
Safe path string
Example

Escape a file path for git commands

const safePath = escapeFilePath('src/utils/helper.ts')
// => 'src/utils/helper.ts'
escapeFilePath('file$name.ts') // throws - '$' is invalid
§function

escapeGitArg(arg: string): string

Escapes a general git argument for safe use in shell commands.
Parameters
NameTypeDescription
§arg
stringArgument to escape
Returns
string
Safe argument string
Example

Escape a git argument for shell commands

escapeGitArg('John Doe <john@example.com>') // => 'John Doe <john@example.com>'
§function

escapeGitMessage(message: string): string

Escapes a message for safe use in git commands.
Parameters
NameTypeDescription
§message
stringMessage to escape
Returns
string
Safe message string
Example

Escape a git commit message

const safeMessage = escapeGitMessage('Release v1.0.0 "stable"')
// => 'Release v1.0.0 \"stable\"'
§function

escapeGitPath(path: string): string

Escapes a file path for safe use in git commands.
Parameters
NameTypeDescription
§path
stringPath to escape
Returns
string
Safe path string
Example

Escape a file path for git commands

escapeGitPath('src/utils/helper.ts') // => 'src/utils/helper.ts'
escapeGitPath('path with spaces/file.ts') // => 'path with spaces/file.ts'
§function

escapeGitRef(ref: string): string

Escapes a git reference for safe use in shell commands.
Parameters
NameTypeDescription
§ref
stringReference to escape
Returns
string
Safe reference string
Example

Escape a git reference for shell commands

escapeGitRef('refs/heads/main') // => 'refs/heads/main'
escapeGitRef('feature/test') // => 'feature/test'
escapeGitRef('ref$invalid') // throws - '$' is invalid
§function

escapeGitTagPattern(pattern: string): string

Escapes a tag pattern for safe use in git commands.
Parameters
NameTypeDescription
§pattern
stringPattern to escape
Returns
string
Safe pattern string
Example

Escape a tag pattern for git commands

const safePattern = escapeGitTagPattern('@scope/package@')
// => '@scope/package@'
escapeGitTagPattern('v1.0.*') // throws - '*' is invalid
§function

getAheadCount(options: GitStatusOptions): number

Gets the number of commits ahead of upstream.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
number
Number of commits ahead
Example

Get commits ahead of upstream

const ahead = getAheadCount()
console.log(`${ahead} commits to push`)
§function

getBehindCount(options: GitStatusOptions): number

Gets the number of commits behind upstream.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
number
Number of commits behind
Example

Get commits behind upstream

const behind = getBehindCount()
console.log(`${behind} commits to pull`)
§function

getChangedFilesBetween(base: string, head: string, options: DiffOptions): unknown

Gets files changed between two git refs.
Uses git diff --name-only base...head which computes the merge-base internally, giving files changed in head since diverging from base.
Parameters
NameTypeDescription
§base
stringBase reference (e.g., 'origin/main', 'v1.0.0')
§head
stringHead reference (defaults to 'HEAD')(default: 'HEAD')
§options
DiffOptionsAdditional options(default: {})
Returns
unknown
Deduplicated list of changed file paths (relative to repo root)
Example
Get changed files between refs
// Files changed since diverging from main
const files = getChangedFilesBetween('origin/main')

// Files changed between two tags
const files = getChangedFilesBetween('v1.0.0', 'v2.0.0')
§function

getChangedFilesBetweenWithStatus(base: string, head: string, options: DiffOptions): unknown

Gets files changed between two refs with status information.
Parameters
NameTypeDescription
§base
stringBase reference
§head
stringHead reference (defaults to 'HEAD')(default: 'HEAD')
§options
DiffOptionsAdditional options(default: {})
Returns
unknown
Array of file changes with status
Example
Get file changes with status information
const changes = getChangedFilesBetweenWithStatus('v1.0.0', 'v2.0.0')
const added = changes.filter(c => c.status === 'added')
§function

getCommit(hash: string, options: Pick<GitLogOptions, "cwd" | "timeout">): GitCommit

Gets a single commit by its hash.
Parameters
NameTypeDescription
§hash
stringCommit hash (full or short)
§options
Pick<GitLogOptions, "cwd" | "timeout">Additional options(default: {})
Returns
GitCommit
GitCommit or null if not found
Example
Get a single commit by hash
const commit = getCommit('abc1234')
§function

getCommitLog(options: GitLogOptions): unknown

Gets the commit log from a git repository.
Parameters
NameTypeDescription
§options
GitLogOptionsConfiguration for retrieving the commit log(default: {})
Returns
unknown
Array of GitCommit objects
Example
Get commit log with options
const commits = getCommitLog({ maxCount: 10 })
const recentChanges = getCommitLog({ from: 'v1.0.0', to: 'HEAD' })
§function

getCommitsBetween(from: string, to: string, options: Omit<GitLogOptions, "from" | "to">): unknown

Gets commits between two references.
Parameters
NameTypeDescription
§from
stringStarting reference (exclusive)
§to
stringEnding reference (inclusive, default: HEAD)(default: 'HEAD')
§options
Omit<GitLogOptions, "from" | "to">Additional options(default: {})
Returns
unknown
Array of GitCommit objects
Example
Get commits between two references
const commits = getCommitsBetween('v1.0.0', 'v1.1.0')
§function

getCommitsSince(since: string, options: Omit<GitLogOptions, "from">): unknown

Gets commits since a specific tag or reference.
Parameters
NameTypeDescription
§since
stringReference to start from (exclusive)
§options
Omit<GitLogOptions, "from">Additional options(default: {})
Returns
unknown
Array of GitCommit objects
Example
Get commits since a tag
const commits = getCommitsSince('v1.0.0')
§function

getCommitWithFiles(hash: string, options: DiffOptions): GitCommitWithFiles

Gets a commit with its changed files.
Uses git diff-tree to retrieve file changes for a single commit. More efficient than fetching files for all commits when only specific commits need file attribution.
Parameters
NameTypeDescription
§hash
stringCommit hash (full or abbreviated)
§options
DiffOptionsAdditional options(default: {})
Returns
GitCommitWithFiles
Commit with files, or null if not found
Example
Get commit with its changed files
const commit = getCommitWithFiles('abc123')
if (commit) {
  console.log(`${commit.subject} touched ${commit.files.length} files`)
}
§function

getCurrentBranch(options: GitCommitOptions): string

Gets the current branch name.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the operation(default: {})
Returns
string
Branch name or null if detached
Example
Get the current branch name
const branch = getCurrentBranch()
§function

getHead(options: GitCommitOptions): string

Gets the current HEAD commit hash.
Parameters
NameTypeDescription
§options
GitCommitOptionsGit operation configuration(default: {})
Returns
string
HEAD commit hash or null
Example
Get the current HEAD commit
const head = getHead()
§function

getHeadHash(options: GitStatusOptions): string

Gets the current commit hash (HEAD).
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
string
Commit hash or null
Example

Get the current HEAD commit hash

const hash = getHeadHash()
// => 'abc123def456789012345678901234567890abcd'
§function

getHeadShortHash(options: GitStatusOptions): string

Gets the short current commit hash.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
string
Short hash or null
Example

Get the short HEAD commit hash

const shortHash = getHeadShortHash()
// => 'abc123d'
§function

getLatestTag(options: ListTagsOptions): GitTag

Gets the latest tag (by creation date).
Parameters
NameTypeDescription
§options
ListTagsOptionsTag options with optional pattern(default: {})
Returns
GitTag
Latest GitTag or null
Example
Get the latest tag by creation date
const latest = getLatestTag()
const latestVersion = getLatestTag({ pattern: 'v' })
§function

getModifiedFiles(options: GitStatusOptions): unknown

Gets list of modified file paths (unstaged).
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
unknown
Array of modified file paths
Example

Get list of modified files

const modified = getModifiedFiles()
// => ['src/utils.ts', 'README.md']
§function

getOperationState(options: GitCommitOptions): GitOperationState

Detects if git is mid-operation (rebase, merge, patch apply).
Uses filesystem checks on .git/ state files rather than git commands. This is more reliable because file existence checks are atomic OS syscalls that work even when the git index is corrupted or git commands would hang.
Handles worktrees, submodules, and $GIT_DIR overrides via git rev-parse --git-dir.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the state check(default: {})
Returns
GitOperationState
Operation state with reason if in progress
Example
Detect if git is mid-operation
const state = getOperationState()
if (state.inProgress) {
  console.warn(`Cannot proceed: git ${state.reason} in progress`)
}
§function

getRepositoryRoot(options: GitStatusOptions): string

Gets the repository root directory.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
string
Root directory path or null
Example
Get the repository root directory
const root = getRepositoryRoot()
§function

getStagedFiles(options: GitStatusOptions): unknown

Gets list of staged file paths.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
unknown
Array of staged file paths
Example

Get list of staged files

const staged = getStagedFiles()
// => ['src/index.ts', 'package.json']
§function

getStatus(options: GitStatusOptions): RepositoryStatus

Gets the full repository status.
Parameters
NameTypeDescription
§options
GitStatusOptionsConfiguration for the status query(default: {})
Returns
RepositoryStatus
Comprehensive repository status information
Example
Get the full repository status
const status = getStatus()
if (!status.clean) {
  console.log('Working tree has changes')
}
§function

getTag(name: string, options: GitTagOptions): GitTag

Gets detailed information about a specific tag.
Parameters
NameTypeDescription
§name
stringThe tag name to look up
§options
GitTagOptionsConfiguration for the tag operation(default: {})
Returns
GitTag
GitTag or null if not found
Example
Get detailed information about a specific tag
const tag = getTag('v1.0.0')
§function

getTags(options: ListTagsOptions): unknown

Gets all tags from the repository.
Parameters
NameTypeDescription
§options
ListTagsOptionsTag listing options(default: {})
Returns
unknown
Array of GitTag objects
Example
Get all tags from the repository
const tags = getTags()
const versionTags = getTags({ pattern: 'v' })
§function

getTagsForPackage(packageName: string, options: ListTagsOptions): unknown

Gets tags that match a package name.
Parameters
NameTypeDescription
§packageName
stringPackage name to match
§options
ListTagsOptionsTag options(default: {})
Returns
unknown
Array of matching tags
Example
Get tags matching a package name
const tags = getTagsForPackage('@scope/pkg')
§function

getUntrackedFiles(options: GitStatusOptions): unknown

Gets list of untracked file paths.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
unknown
Array of untracked file paths
Example

Get list of untracked files

const untracked = getUntrackedFiles()
// => ['new-file.ts', 'temp.log']
§function

hasConflicts(options: GitStatusOptions): boolean

Checks if there are merge conflicts.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
boolean
True if there are conflicts
Example

Check for merge conflicts

if (hasConflicts()) {
  console.log('Resolve merge conflicts before continuing')
}
§function

hasStagedChanges(options: GitCommitOptions): boolean

Checks if there are staged changes.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the operation(default: {})
Returns
boolean
True if there are staged changes ready to commit
Example
Check for staged changes before committing
if (hasStagedChanges()) { createCommit('...') }
§function

hasUnstagedChanges(options: GitCommitOptions): boolean

Checks if there are unstaged changes (working tree dirty).
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the operation(default: {})
Returns
boolean
True if there are unstaged changes in the working tree
Example
Check for unstaged changes before staging
if (hasUnstagedChanges()) { stage(['.']) }
§function

hasUntrackedFiles(options: GitCommitOptions): boolean

Checks if there are untracked files.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the operation(default: {})
Returns
boolean
True if there are untracked files in the working directory
Example

Check for untracked files

if (hasUntrackedFiles()) {
  console.log('New files detected that are not tracked by git')
}
§function

isClean(options: GitStatusOptions): boolean

Checks if the working tree is clean (no changes).
Parameters
NameTypeDescription
§options
GitStatusOptionsConfiguration for the status check(default: {})
Returns
boolean
True if working tree is clean with no uncommitted changes
Example
Check if working tree is clean
if (!isClean()) {
  throw new Error('Working tree has changes')
}
§function

isGitRepository(options: GitStatusOptions): boolean

Checks if the directory is a git repository.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
boolean
True if in a git repository
Example
Check if directory is a git repository
if (!isGitRepository()) {
  throw new Error('Not a git repository')
}
§function

isOperationInProgress(options: GitCommitOptions): boolean

Checks if git is in the middle of an incomplete operation.
Convenience wrapper around getOperationState() for simple checks. Use getOperationState() directly when you need to know which operation is in progress.
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the state check(default: {})
Returns
boolean
True if rebase, merge, or other operation is incomplete
Example
Check for incomplete operations
if (isOperationInProgress()) {
  throw new Error('Complete or abort the current git operation first')
}
§function

needsPull(options: GitStatusOptions): boolean

Checks if the repository needs to be pulled.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
boolean
True if there are commits to pull
Example

Check if repository needs to be pulled

if (needsPull()) {
  console.log('Remote commits need to be pulled')
}
§function

needsPush(options: GitStatusOptions): boolean

Checks if the repository needs to be pushed.
Parameters
NameTypeDescription
§options
GitStatusOptionsStatus options(default: {})
Returns
boolean
True if there are unpushed commits
Example

Check if repository needs to be pushed

if (needsPush()) {
  console.log('Local commits need to be pushed')
}
§function

pushTag(name: string, remote: string, options: GitTagOptions): boolean

Pushes a tag to a remote.
Parameters
NameTypeDescription
§name
stringThe tag to push to the remote
§remote
stringRemote name (defaults to 'origin')(default: 'origin')
§options
GitTagOptionsConfiguration for the tag operation(default: {})
Returns
boolean
True if pushed successfully
Example
Push a tag to remote
pushTag('v1.0.0')
pushTag('v1.0.0', 'upstream')
§function

stage(files: unknown, options: StageOptions): boolean

Stages files for commit.
Parameters
NameTypeDescription
§files
unknownArray of file paths relative to working directory
§options
StageOptionsConfiguration for the staging operation(default: {})
Returns
boolean
True if staging succeeded
Example
Stage files for commit
stage(['package.json', 'CHANGELOG.md'])
stage(['.'], { all: true })
§function

stageAll(options: GitCommitOptions): boolean

Stages all changes (tracked and untracked).
Parameters
NameTypeDescription
§options
GitCommitOptionsConfiguration for the staging operation(default: {})
Returns
boolean
True if all changes were successfully added to the index
Example
Stage all tracked and untracked changes
stageAll() // stages all tracked and untracked changes
§function

tagExists(name: string, options: GitTagOptions): boolean

Checks if a tag exists.
Parameters
NameTypeDescription
§name
stringThe tag name to verify
§options
GitTagOptionsConfiguration for the tag operation(default: {})
Returns
boolean
True if tag exists
Example
Check if a tag exists
if (tagExists('v1.0.0')) { ... }
§function

unstage(files: unknown, options: GitCommitOptions): boolean

Unstages files.
Parameters
NameTypeDescription
§files
unknownArray of file paths to remove from staging area
§options
GitCommitOptionsConfiguration for the unstage operation(default: {})
Returns
boolean
True if unstaging succeeded
Example
Unstage files from the index
unstage(['package.json'])

◈ Interfaces

§interface

CreateCommitOptions

Options for creating a commit.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§readonly body?:stringCommit message body (separate from subject)
§readonly allowEmpty?:booleanAllow empty commit (no changes)
§readonly amend?:booleanAmend the last commit
§readonly noEdit?:booleanKeep the existing commit message when amending (requires amend: true)
§readonly sign?:booleanSign the commit with GPG
§readonly noVerify?:booleanDon't run pre-commit hooks
§readonly author?:stringAuthor (format: "Name <email>")
§readonly files?:unknownSpecific files to commit (instead of all staged)
§interface

CreateTagOptions

Options for creating a tag.
Properties
§readonly message?:stringTag message (creates annotated tag if provided)
§readonly target?:stringTarget commit (defaults to HEAD)
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly force?:booleanForce overwrite if tag exists
§readonly timeout?:numberTimeout in milliseconds
§interface

DiffOptions

Options for diff-based queries.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§interface

DiscardChangesOptions

Options for discarding changes.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly files?:unknownFiles or directories to discard. If empty/undefined, discards ALL changes. Paths are relative to the working directory.
§readonly timeout?:numberTimeout in milliseconds
§interface

FileChange

A file changed in a commit or between refs.
Properties
§readonly path:stringFile path relative to repository root
§readonly status:FileChangeStatusType of change
§readonly oldPath?:stringOriginal path for renames/copies
§interface

FileStatusEntry

Detailed file status.
Properties
§readonly path:stringFile path
§readonly indexStatus:FileStatusIndex (staging area) status
§readonly workTreeStatus:FileStatusWorking tree status
§readonly origPath?:stringOriginal path for renamed/copied files
§interface

GitCommitOptions

Options for commit operations.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§interface

GitCommitWithFiles

A git commit with file change information.
Properties
§readonly hash:stringFull commit hash (40 characters)
§readonly shortHash:stringAbbreviated commit hash (typically 7 characters)
§readonly authorName:stringCommit author name
§readonly authorEmail:stringCommit author email
§readonly authorDate:stringAuthor date (ISO 8601 format)
§readonly committerName:stringCommitter name
§readonly committerEmail:stringCommitter email
§readonly commitDate:stringCommit date (ISO 8601 format)
§readonly subject:stringCommit subject (first line of message)
§readonly body:stringFull commit body (excludes subject)
§readonly message:stringFull commit message (subject + body)
§readonly parents:unknownParent commit hashes
§readonly files:unknownFiles changed in this commit
§readonly refs:unknownAssociated refs (branches, tags, etc.)
§interface

GitLogOptions

Options for git log operations.
Properties
§readonly maxCount?:numberMaximum number of commits to retrieve. Zero retrieves every matching commit.
§readonly from?:stringStarting commit reference (inclusive)
§readonly to?:stringEnding commit reference (exclusive)
§readonly path?:stringFile path to filter commits by
§readonly author?:stringAuthor to filter by
§readonly includeMerges?:booleanInclude merge commits
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§interface

GitOperationState

Result of checking git's operation state.
Properties
§readonly inProgress:booleanTrue if git is mid-operation (rebase, merge, etc.)
§readonly reason:GitOperationStateReasonWhich operation is in progress, if any. Returns the first detected state (exit-early pattern).
§readonly details:GitOperationStateDetailsDetailed state for each check performed. Useful for diagnostics or when multiple states could theoretically overlap.
§interface

GitStatusOptions

Options for status operations.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§interface

GitTagOptions

Options for tag operations.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§interface

ListTagsOptions

Options for listing tags.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§readonly pattern?:stringPattern to filter tags by (prefix match)
§readonly sortByVersion?:booleanSort by version (descending)
§readonly maxCount?:numberMaximum number of tags to return
§interface

RepositoryStatus

Repository status summary.
Properties
§readonly branch:stringCurrent branch name
§readonly detached:booleanWhether HEAD is detached
§readonly upstream?:stringUpstream branch (if tracking)
§readonly ahead:numberCommits ahead of upstream
§readonly behind:numberCommits behind upstream
§readonly staged:unknownStaged files
§readonly modified:unknownModified files (unstaged)
§readonly untracked:unknownUntracked files
§readonly clean:booleanWhether working tree is clean
§readonly hasConflicts:booleanWhether there are merge conflicts
§interface

StageOptions

Options for staging files.
Properties
§readonly cwd?:stringWorking directory (defaults to cwd)
§readonly timeout?:numberTimeout in milliseconds
§readonly all?:booleanStage all changes (including untracked)
§readonly update?:booleanUpdate tracked files only
§readonly force?:booleanForce add (ignore gitignore)

◆ Types

§type

FileChangeStatus

File change status codes matching git conventions.
type FileChangeStatus = "added" | "modified" | "deleted" | "renamed" | "copied"
§type

FileStatus

File status in a git repository.
type FileStatus = "modified" | "added" | "deleted" | "renamed" | "copied" | "untracked" | "ignored" | "unmerged"
§type

GitOperationStateOptions

Options for operation state check.
type GitOperationStateOptions = GitCommitOptions
§type

GitOperationStateReason

Reasons why git may be in an unstable operation state.
These correspond to state files that git creates during multi-step operations:
  • 'rebase-interactive': .git/rebase-merge exists (interactive rebase paused)
  • 'rebase-apply': .git/rebase-apply exists (mailbox-based rebase or git am)
  • 'merge-in-progress': .git/MERGE_HEAD exists (merge awaiting conflict resolution)
type GitOperationStateReason = "rebase-interactive" | "rebase-apply" | "merge-in-progress"

● Variables

§type

DEFAULT_COMMIT_OPTIONS

Default commit options.
§type

DEFAULT_DIFF_OPTIONS

Default diff options.
§type

DEFAULT_LOG_OPTIONS

Default log options.
§type

DEFAULT_OPERATION_STATE_OPTIONS

Default options for operation state checks.
§type

DEFAULT_STATUS_OPTIONS

Default status options.
§type

DEFAULT_TAG_OPTIONS

Default tag options.