Skip to main content
// Delete a persistent branch
const result = await repo.deleteBranch({
  name: "feature/old-onboarding",
});

console.log(result.message);

// Delete an ephemeral branch
const ephemeralResult = await repo.deleteBranch({
  name: "merge/8e831bf0-3f19-45dc-b9b9-8aad571c9017",
  ephemeral: true,
});
Branch names must not start with refs/. The repository’s default branch cannot be deleted. This protection only applies to non-ephemeral branches — an ephemeral branch that shares the same short name as the default branch can still be deleted.

Options

name
string
required
Branch name to delete (e.g. feature/old-onboarding). Must not start with refs/.
ephemeral
boolean
Delete from the ephemeral namespace instead of the persistent one (default: false). Use this to clean up branches created with ephemeral: true.
refPolicies
object[]
Ordered per-ref policy rules ({ pattern, ops? }) embedded in the per-call JWT. First match wins. Python: ref_policies. Go: RefPolicies with type storage.RefPolicyList. See the Branch Protection guide.

Response

name
string
The deleted branch name.
ephemeral
boolean
Whether the deleted branch was in the ephemeral namespace.
message
string
Confirmation message from the API.