- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
DeleteBranchCommand
Deletes a branch from a repository, unless that branch is the default branch for the repository.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CodeCommitClient, DeleteBranchCommand } from "@aws-sdk/client-codecommit"; // ES Modules import
// const { CodeCommitClient, DeleteBranchCommand } = require("@aws-sdk/client-codecommit"); // CommonJS import
const client = new CodeCommitClient(config);
const input = { // DeleteBranchInput
repositoryName: "STRING_VALUE", // required
branchName: "STRING_VALUE", // required
};
const command = new DeleteBranchCommand(input);
const response = await client.send(command);
// { // DeleteBranchOutput
// deletedBranch: { // BranchInfo
// branchName: "STRING_VALUE",
// commitId: "STRING_VALUE",
// },
// };
DeleteBranchCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
branchName Required | string | undefined | The name of the branch to delete. |
repositoryName Required | string | undefined | The name of the repository that contains the branch to be deleted. |
DeleteBranchCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
deletedBranch | BranchInfo | undefined | Information about the branch deleted by the operation, including the branch name and the commit ID that was the tip of the branch. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BranchNameRequiredException | client | A branch name is required, but was not specified. |
DefaultBranchCannotBeDeletedException | client | The specified branch is the default branch for the repository, and cannot be deleted. To delete this branch, you must first set another branch as the default branch. |
EncryptionIntegrityChecksFailedException | server | An encryption integrity check failed. |
EncryptionKeyAccessDeniedException | client | An encryption key could not be accessed. |
EncryptionKeyDisabledException | client | The encryption key is disabled. |
EncryptionKeyNotFoundException | client | No encryption key was found. |
EncryptionKeyUnavailableException | client | The encryption key is not available. |
InvalidBranchNameException | client | The specified reference name is not valid. |
InvalidRepositoryNameException | client | A specified repository name is not valid. This exception occurs only when a specified repository name is not valid. Other exceptions occur when a required repository parameter is missing, or when a specified repository does not exist. |
RepositoryDoesNotExistException | client | The specified repository does not exist. |
RepositoryNameRequiredException | client | A repository name is required, but was not specified. |
CodeCommitServiceException | Base exception class for all service exceptions from CodeCommit service. |