- 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.
CreateBranchCommand
Creates a branch in a repository and points the branch to a commit.
Calling the create branch operation does not set a repository's default branch. To do this, call the update default branch operation.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CodeCommitClient, CreateBranchCommand } from "@aws-sdk/client-codecommit"; // ES Modules import
// const { CodeCommitClient, CreateBranchCommand } = require("@aws-sdk/client-codecommit"); // CommonJS import
const client = new CodeCommitClient(config);
const input = { // CreateBranchInput
repositoryName: "STRING_VALUE", // required
branchName: "STRING_VALUE", // required
commitId: "STRING_VALUE", // required
};
const command = new CreateBranchCommand(input);
const response = await client.send(command);
// {};
CreateBranchCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
branchName Required | string | undefined | The name of the new branch to create. |
commitId Required | string | undefined | The ID of the commit to point the new branch to. |
repositoryName Required | string | undefined | The name of the repository in which you want to create the new branch. |
CreateBranchCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BranchNameExistsException | client | Cannot create the branch with the specified name because the commit conflicts with an existing branch with the same name.Branch names must be unique. |
BranchNameRequiredException | client | A branch name is required, but was not specified. |
CommitDoesNotExistException | client | The specified commit does not exist or no commit was specified, and the specified repository has no default branch. |
CommitIdRequiredException | client | A commit ID was not specified. |
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. |
InvalidCommitIdException | client | The specified commit ID 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. |