Skip to main content
const branch = await repo.createBranch({
  baseBranch: "main", // source branch
  targetBranch: "feature/new-onboarding",
  // baseIsEphemeral: true,
  // targetIsEphemeral: true,
});

console.log(branch.targetBranch); // 'feature/new-onboarding'
console.log(branch.commitSha); // tip SHA when available
Toggle baseIsEphemeral/targetIsEphemeral to work with ephemeral refs. The method returns the API message plus the resolved branch metadata so you can confirm creation before pushing commits.

Options

baseBranch
string
required
Source branch to copy from. Combine with baseIsEphemeral when promoting from the ephemeral namespace.
targetBranch
string
required
Destination branch name. May match baseBranch when moving between namespaces.
baseIsEphemeral
string
true when the source branch lives in the ephemeral namespace (defaults to false).
targetIsEphemeral
string
true to create/update an ephemeral branch instead of the default namespace.

Response

message
string
Confirmation message
targetBranch
string
The created branch name
targetIsEphemeral
boolean
Whether the branch is in the ephemeral namespace
commitSha
string
The tip commit SHA of the new branch