- 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.
MergeBranchesByThreeWayCommand
Merges two specified branches using the three-way merge strategy.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CodeCommitClient, MergeBranchesByThreeWayCommand } from "@aws-sdk/client-codecommit"; // ES Modules import
// const { CodeCommitClient, MergeBranchesByThreeWayCommand } = require("@aws-sdk/client-codecommit"); // CommonJS import
const client = new CodeCommitClient(config);
const input = { // MergeBranchesByThreeWayInput
repositoryName: "STRING_VALUE", // required
sourceCommitSpecifier: "STRING_VALUE", // required
destinationCommitSpecifier: "STRING_VALUE", // required
targetBranch: "STRING_VALUE",
conflictDetailLevel: "FILE_LEVEL" || "LINE_LEVEL",
conflictResolutionStrategy: "NONE" || "ACCEPT_SOURCE" || "ACCEPT_DESTINATION" || "AUTOMERGE",
authorName: "STRING_VALUE",
email: "STRING_VALUE",
commitMessage: "STRING_VALUE",
keepEmptyFolders: true || false,
conflictResolution: { // ConflictResolution
replaceContents: [ // ReplaceContentEntries
{ // ReplaceContentEntry
filePath: "STRING_VALUE", // required
replacementType: "KEEP_BASE" || "KEEP_SOURCE" || "KEEP_DESTINATION" || "USE_NEW_CONTENT", // required
content: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
fileMode: "EXECUTABLE" || "NORMAL" || "SYMLINK",
},
],
deleteFiles: [ // DeleteFileEntries
{ // DeleteFileEntry
filePath: "STRING_VALUE", // required
},
],
setFileModes: [ // SetFileModeEntries
{ // SetFileModeEntry
filePath: "STRING_VALUE", // required
fileMode: "EXECUTABLE" || "NORMAL" || "SYMLINK", // required
},
],
},
};
const command = new MergeBranchesByThreeWayCommand(input);
const response = await client.send(command);
// { // MergeBranchesByThreeWayOutput
// commitId: "STRING_VALUE",
// treeId: "STRING_VALUE",
// };
MergeBranchesByThreeWayCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
destinationCommitSpecifier Required | string | undefined | The branch, tag, HEAD, or other fully qualified reference used to identify a commit (for example, a branch name or a full commit ID). |
repositoryName Required | string | undefined | The name of the repository where you want to merge two branches. |
sourceCommitSpecifier Required | string | undefined | The branch, tag, HEAD, or other fully qualified reference used to identify a commit (for example, a branch name or a full commit ID). |
authorName | string | undefined | The name of the author who created the commit. This information is used as both the author and committer for the commit. |
commitMessage | string | undefined | The commit message to include in the commit information for the merge. |
conflictDetailLevel | ConflictDetailLevelTypeEnum | undefined | The level of conflict detail to use. If unspecified, the default FILE_LEVEL is used, which returns a not-mergeable result if the same file has differences in both branches. If LINE_LEVEL is specified, a conflict is considered not mergeable if the same file in both branches has differences on the same line. |
conflictResolution | ConflictResolution | undefined | If AUTOMERGE is the conflict resolution strategy, a list of inputs to use when resolving conflicts during a merge. |
conflictResolutionStrategy | ConflictResolutionStrategyTypeEnum | undefined | Specifies which branch to use when resolving conflicts, or whether to attempt automatically merging two versions of a file. The default is NONE, which requires any conflicts to be resolved manually before the merge operation is successful. |
email | string | undefined | The email address of the person merging the branches. This information is used in the commit information for the merge. |
keepEmptyFolders | boolean | undefined | If the commit contains deletions, whether to keep a folder or folder structure if the changes leave the folders empty. If true, a .gitkeep file is created for empty folders. The default is false. |
targetBranch | string | undefined | The branch where the merge is applied. |
MergeBranchesByThreeWayCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
commitId | string | undefined | The commit ID of the merge in the destination or target branch. |
treeId | string | undefined | The tree ID of the merge in the destination or target branch. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
BranchDoesNotExistException | client | The specified branch does not exist. |
BranchNameIsTagNameException | client | The specified branch name is not valid because it is a tag name. Enter the name of a branch in the repository. For a list of valid branch names, use ListBranches. |
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. |
CommitMessageLengthExceededException | client | The commit message is too long. Provide a shorter string. |
CommitRequiredException | client | A commit was not specified. |
ConcurrentReferenceUpdateException | client | The merge cannot be completed because the target branch has been modified. Another user might have modified the target branch while the merge was in progress. Wait a few minutes, and then try again. |
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. |
FileContentSizeLimitExceededException | client | The file cannot be added because it is too large. The maximum file size is 6 MB, and the combined file content change size is 7 MB. Consider making these changes using a Git client. |
FileModeRequiredException | client | The commit cannot be created because no file mode has been specified. A file mode is required to update mode permissions for a file. |
FolderContentSizeLimitExceededException | client | The commit cannot be created because at least one of the overall changes in the commit results in a folder whose contents exceed the limit of 6 MB. Either reduce the number and size of your changes, or split the changes across multiple folders. |
InvalidBranchNameException | client | The specified reference name is not valid. |
InvalidCommitException | client | The specified commit is not valid. |
InvalidConflictDetailLevelException | client | The specified conflict detail level is not valid. |
InvalidConflictResolutionException | client | The specified conflict resolution list is not valid. |
InvalidConflictResolutionStrategyException | client | The specified conflict resolution strategy is not valid. |
InvalidEmailException | client | The specified email address either contains one or more characters that are not allowed, or it exceeds the maximum number of characters allowed for an email address. |
InvalidFileModeException | client | The specified file mode permission is not valid. For a list of valid file mode permissions, see PutFile. |
InvalidPathException | client | The specified path is not valid. |
InvalidReplacementContentException | client | Automerge was specified for resolving the conflict, but the replacement type is not valid or content is missing. |
InvalidReplacementTypeException | client | Automerge was specified for resolving the conflict, but the specified replacement type 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. |
InvalidTargetBranchException | client | The specified target branch is not valid. |
ManualMergeRequiredException | client | The pull request cannot be merged automatically into the destination branch. You must manually merge the branches and resolve any conflicts. |
MaximumConflictResolutionEntriesExceededException | client | The number of allowed conflict resolution entries was exceeded. |
MaximumFileContentToLoadExceededException | client | The number of files to load exceeds the allowed limit. |
MaximumItemsToCompareExceededException | client | The number of items to compare between the source or destination branches and the merge base has exceeded the maximum allowed. |
MultipleConflictResolutionEntriesException | client | More than one conflict resolution entries exists for the conflict. A conflict can have only one conflict resolution entry. |
NameLengthExceededException | client | The user name is not valid because it has exceeded the character limit for author names. |
PathRequiredException | client | The folderPath for a location cannot be null. |
ReplacementContentRequiredException | client | USE_NEW_CONTENT was specified, but no replacement content has been provided. |
ReplacementTypeRequiredException | client | A replacement type is required. |
RepositoryDoesNotExistException | client | The specified repository does not exist. |
RepositoryNameRequiredException | client | A repository name is required, but was not specified. |
TipsDivergenceExceededException | client | The divergence between the tips of the provided commit specifiers is too great to determine whether there might be any merge conflicts. Locally compare the specifiers using |
CodeCommitServiceException | Base exception class for all service exceptions from CodeCommit service. |