Skip to main content
Version: 1.0-beta

GitRef

API reference

A git ref (tag, branch, or commit).

Implements Node

commit
The resolved commit id at this ref.
commitSHA
The resolved commit SHA at this ref.
id
A unique identifier for this GitRef.
name
The resolved name of this ref.
ref
The resolved ref name at this ref.
asRepository
Return this ref's repository with HEAD pinned to the selected commit.
asWorkspace
Creates a synthetic workspace from this git ref.
commonAncestor
Find the best common ancestor between this ref and another ref.
log
Commits reachable from this ref, newest first, starting with the commit this ref resolves to.
push
Push this ref's commit and history to a remote repository using the destination's credentials.
targetCommit
The commit this ref resolves to.
tree
The filesystem tree at this ref.
withCommit
Create a single-parent commit on this ref by applying a changeset's edits.

commit: String!Deprecated

The resolved commit id at this ref.

Deprecated: Use "commitSHA" instead.

commitSHA: String!

The resolved commit SHA at this ref.

id: ID!

A unique identifier for this GitRef.

name: String!

The resolved name of this ref.

ref: String!Deprecated

The resolved ref name at this ref.

Deprecated: Use "name" instead.

asRepository: GitRepository!

Return this ref's repository with HEAD pinned to the selected commit.

Preserves the original repository backend, connection information, and other refs. Does not modify a branch or checkout, or prune history.

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

Creates a synthetic workspace from this git ref.

cwd: String = "/"

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

commonAncestor(other: GitRef!): GitRef!

Find the best common ancestor between this ref and another ref.

other: GitRef!

The other ref to compare against.

log(limit: Int = 10,paths: [String!],base: GitRef): [GitCommit!]!

Commits reachable from this ref, newest first, starting with the commit this ref resolves to.

limit: Int = 10

Maximum number of commits to return.

paths: [String!]

Only include commits touching these paths, relative to the root of the repository.

base: GitRef

Exclude commits reachable from this ref, i.e. only list commits added on top of it.

push(to: GitRepository,remote: String = "",branch: String = "",expectedRemoteSHA: String = ""): GitPushResult!

Push this ref's commit and history to a remote repository using the destination's credentials.

The source can come from a remote repository or an engine-side Git repository. To publish a workspace's commits, use Workspace.git.head.push. Pushing does not modify the calling client's checkout, and checkout hooks do not run.

A missing remote ref is created. Without a lease, Git's normal non-force rules apply. Each invocation performs a push; loading the returned receipt does not push again.

to: GitRepository

Destination remote repository. Defaults to the origin remote's push routing, or the source's repository URL when none is registered. Required when the source has no remote URL.

remote: String = ""

Name of a registered remote to push to (see GitRepository.withRemote). Defaults to origin. The remote's push URLs, or its URL, become the destination; more than one push URL requires an explicit to instead.

branch: String = ""

Destination branch; a refs/ prefix is used verbatim. Defaults to this ref's branch name. Required for detached and non-branch refs.

expectedRemoteSHA: String = ""

Optional lease: a full lowercase object ID allows replacement only if the remote ref still has that value. Checked even for up-to-date pushes. Empty or omitted uses normal non-force rules, creating the ref if it does not exist.

targetCommit: GitCommit!

The commit this ref resolves to.

tree(discardGitDir: Boolean = false,depth: Int = 1,includeTags: Boolean = false): Directory!

The filesystem tree at this ref.

discardGitDir: Boolean = false

Set to true to discard .git directory.

depth: Int = 1

The depth of the tree to fetch.

includeTags: Boolean = false

Set to true to populate tag refs in the local checkout .git.

withCommit(changes: Changeset!,message: String!,date: String!,authorName: String!,authorEmail: String!,committerName: String,committerEmail: String,committerDate: String,allowEmpty: Boolean = false,signoff: Boolean = false): GitRef!

Create a single-parent commit on this ref by applying a changeset's edits.

Three-way merges the changeset against this ref's tree, using its before snapshot as the base. Preserves compatible parent edits and fails on conflicts. Does not modify the input repository or host checkout.

Identity and dates are explicit; neither client Git configuration nor the current clock is consulted.

changes: Changeset!

Changes to apply. Use Changeset.filter to select paths before committing.

message: String!

Commit message.

date: String!

RFC3339 author date; also the default committer date.

authorName: String!

Author name.

authorEmail: String!

Author email.

committerName: String

Committer name. Defaults to authorName.

committerEmail: String

Committer email. Defaults to authorEmail.

committerDate: String

RFC3339 committer date. Defaults to date.

allowEmpty: Boolean = false

Allow a commit whose tree matches its parent, including when the supplied edits are already present. Defaults to false.

signoff: Boolean = false

Add a Signed-off-by trailer using the commit author's name and email.

References

Returned by

Accepted as an argument by