Skip to main content
Version: 1.0-beta

GitRepository

The GitRepository type represents a Git repository.

API reference

A git repository.

Implements Node

branches
branches that match any of the given glob patterns.
id
A unique identifier for this GitRepository.
tags
tags that match any of the given glob patterns.
url
The URL of the git repository.
asWorkspace
Creates a synthetic workspace from this repository's HEAD and uncommitted file changes.
branch
Returns details of a branch.
bundle
Pack the given refs and the objects needed to reconstruct them into a Git bundle.
commit
Returns details of a commit.
head
Returns details for HEAD.
latest
Return the latest stable release tag, falling back to HEAD when no release exists.
ref
Returns details of a ref.
tag
Returns details of a tag.
uncommitted
Returns the changeset of uncommitted changes in the git repository.
withBundle
Import a Git bundle after fetching and verifying all of its prerequisites.
withContents
Replace this repository's storage with the supplied self-contained Git repository, retaining its logical URL and push destinations.
withRemote
Register a named remote on this repository, replacing any registered remote of the same name.

branches(patterns: [String!]): [String!]!

branches that match any of the given glob patterns.

patterns: [String!]

Glob patterns (e.g., "refs/tags/v*").

id: ID!

A unique identifier for this GitRepository.

tags(patterns: [String!]): [String!]!

tags that match any of the given glob patterns.

patterns: [String!]

Glob patterns (e.g., "refs/tags/v*").

url: String

The URL of the git repository.

asWorkspace(cwd: String = "/"): Workspace!

Creates a synthetic workspace from this repository's HEAD and uncommitted file changes.

Pending changes are applied at the repository root. The staging split is not preserved. The source repository is not modified.

cwd: String = "/"

Current working directory inside the workspace root. Defaults to the workspace root.

branch(name: String!): GitRef!

Returns details of a branch.

name: String!

Branch's name (e.g., "main").

bundle(refs: [String!]!, base: GitRef): GitBundle!

Pack the given refs and the objects needed to reconstruct them into a Git bundle.

refs: [String!]!

Refs to advertise in the bundle. At least one named ref is required.

base: GitRef

A Git ref whose reachable objects are omitted and recorded as a prerequisite.

commit(id: String!): GitCommit!

Returns details of a commit.

id: String!

Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").

May be abbreviated to an unambiguous hex prefix (4-40 characters), which is expanded against locally available objects. Remote repositories (resolved via ls-remote) can only expand prefixes of already-fetched commits; use the full SHA otherwise.

Returns details for HEAD.

latest(version: String = ""): GitRef!

Return the latest stable release tag, falling back to HEAD when no release exists.

Release selection accepts an optional "v" prefix, incomplete versions, and zero-padded numeric components. This operation is pinned.

version: String = ""

Version query used to select the greatest matching release ref.

ref(name: String!): GitRef!

Returns details of a ref.

name: String!

Ref's name (can be a commit identifier, a tag name, a branch name, or a fully-qualified ref).

Commit identifiers may be abbreviated: an unambiguous hex prefix (4-40 characters) of a commit SHA resolves like git rev-parse, with named refs taking precedence. Abbreviated SHAs resolve against locally available objects, so remote repositories (resolved via ls-remote) can only expand prefixes of already-fetched commits; use the full SHA or a named ref otherwise.

tag(name: String!): GitRef!

Returns details of a tag.

name: String!

Tag's name (e.g., "v0.3.9").

uncommitted: Changeset!

Returns the changeset of uncommitted changes in the git repository.

withBundle(bundle: GitBundle!, prerequisiteRef: String = ""): GitRepository!

Import a Git bundle after fetching and verifying all of its prerequisites.

bundle: GitBundle!

The Git bundle to import.

prerequisiteRef: String = ""

An optional remote ref hint for fetching a prerequisite when the remote does not allow fetches by object ID.

withContents(directory: Directory!): GitRepository!

Replace this repository's storage with the supplied self-contained Git repository, retaining its logical URL and push destinations.

Accepts a whole checkout (including .git and pending file edits), .git contents, or a bare repository. Does not initialize a repository, merge histories, or modify either input.

The receiver's logical routing wins over the supplied Git configuration; that configuration is not rewritten. Use Directory.asGit to open the supplied repository without retaining the receiver's routing.

directory: Directory!

Existing Git storage to open. Git metadata and object dependencies must be contained in this directory.

withRemote(name: String!,url: String!,pushUrl: String = ""): GitRepository!

Register a named remote on this repository, replacing any registered remote of the same name.

Registered remotes are recorded in checkouts materialized from this repository (GitRef.tree, Workspace.git.directory), so remote-aware tooling like gh can resolve and fetch from them. The origin remote also routes push when no explicit destination is passed: its push URL, or its URL, becomes the default destination.

Routing metadata only, never a credential grant: pushes still authenticate with the caller's own credentials and require approval as usual.

name: String!

The remote's name, e.g. "origin" or "upstream".

url: String!

The remote's fetch URL.

pushUrl: String = ""

Push destination, when pushes go somewhere other than url. Empty uses url.

References

Returned by

Accepted as an argument by