

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 的 CodeCommit 範例 AWS CLI
<a name="cli_2_codecommit_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 CodeCommit 執行動作和實作常見案例。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `associate-approval-rule-template-with-repository`
<a name="codecommit_AssociateApprovalRuleTemplateWithRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `associate-approval-rule-template-with-repository`。

**AWS CLI**  
**建立核准規則範本與儲存庫的關聯**  
下列 `associate-approval-rule-template-with-repository` 範例為指定的核准規則範本，與名為 `MyDemoRepo` 的儲存庫建立關聯。  

```
aws codecommit associate-approval-rule-template-with-repository \
    --repository-name MyDemoRepo  \
    --approval-rule-template-name 2-approver-rule-for-main
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[為核准規則範本與儲存庫建立關聯](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-associate-template.html#associate-template-repository)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AssociateApprovalRuleTemplateWithRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/associate-approval-rule-template-with-repository.html)。

### `batch-associate-approval-rule-template-with-repositories`
<a name="codecommit_BatchAssociateApprovalRuleTemplateWithRepositories_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-associate-approval-rule-template-with-repositories`。

**AWS CLI**  
**在單一操作中，為核准規則範本與多個儲存庫建立關聯**  
下列 `batch-associate-approval-rule-template-with-repositories` 範例為指定的核准規則範本，與名為 `MyDemoRepo` 和 `MyOtherDemoRepo` 的儲存庫建立關聯。  
注意：核准規則範本專屬於建立它們 AWS 的區域。它們只能與該 AWS 區域中的儲存庫相關聯。  

```
aws codecommit batch-associate-approval-rule-template-with-repositories \
    --repository-names MyDemoRepo, MyOtherDemoRepo  \
    --approval-rule-template-name 2-approver-rule-for-main
```
輸出：  

```
{
    "associatedRepositoryNames": [
        "MyDemoRepo",
        "MyOtherDemoRepo"
    ],
    "errors": []
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[為核准規則範本與儲存庫建立關聯](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-associate-template.html#batch-associate-template-repositories)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [BatchAssociateApprovalRuleTemplateWithRepositories](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/batch-associate-approval-rule-template-with-repositories.html)。

### `batch-describe-merge-conflicts`
<a name="codecommit_BatchDescribeMergeConflicts_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-describe-merge-conflicts`。

**AWS CLI**  
**取得兩個遞交指標之間的合併當中，所有檔案或部分檔案之合併衝突的相關資訊**  
下列 `batch-describe-merge-conflicts` 範例判斷出在名為 `MyDemoRepo` 的儲存庫中，使用 `THREE_WAY_MERGE` 策略合併名為 `feature-randomizationfeature` 的來源分支，與名為 `main` 的目的地分支的合併衝突。  

```
aws codecommit batch-describe-merge-conflicts \
    --source-commit-specifier feature-randomizationfeature \
    --destination-commit-specifier main \
    --merge-option THREE_WAY_MERGE \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "conflicts": [
        {
            "conflictMetadata": {
                "filePath": "readme.md",
                "fileSizes": {
                    "source": 139,
                    "destination": 230,
                    "base": 85
                },
                "fileModes": {
                    "source": "NORMAL",
                    "destination": "NORMAL",
                    "base": "NORMAL"
                },
                "objectTypes": {
                    "source": "FILE",
                    "destination": "FILE",
                    "base": "FILE"
                },
                "numberOfConflicts": 1,
                "isBinaryFile": {
                    "source": false,
                    "destination": false,
                    "base": false
                },
                "contentConflict": true,
                "fileModeConflict": false,
                "objectTypeConflict": false,
                "mergeOperations": {
                    "source": "M",
                    "destination": "M"
                }
            },
            "mergeHunks": [
                {
                    "isConflict": true,
                    "source": {
                        "startLine": 0,
                        "endLine": 3,
                        "hunkContent": "VGhpcyBpEXAMPLE=="
                    },
                    "destination": {
                        "startLine": 0,
                        "endLine": 1,
                        "hunkContent": "VXNlIHRoEXAMPLE="
                    }
                }
            ]
        }
    ],
    "errors": [],
    "destinationCommitId": "86958e0aEXAMPLE",
    "sourceCommitId": "6ccd57fdEXAMPLE",
    "baseCommitId": "767b6958EXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[解決提取請求中的衝突](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-resolve-conflict-pull-request.html#batch-describe-merge-conflicts)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchDescribeMergeConflicts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/batch-describe-merge-conflicts.html)。

### `batch-disassociate-approval-rule-template-from-repositories`
<a name="codecommit_BatchDisassociateApprovalRuleTemplateFromRepositories_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-disassociate-approval-rule-template-from-repositories`。

**AWS CLI**  
**在單一操作中，取消核准規則範本與多個儲存器的關聯**  
下列 `batch-disassociate-approval-rule-template-from-repositories` 範例取消指定的核准規則範本，與名為 `MyDemoRepo` 和 `MyOtherDemoRepo` 的儲存庫的關聯。  

```
aws codecommit batch-disassociate-approval-rule-template-from-repositories \
    --repository-names MyDemoRepo, MyOtherDemoRepo  \
    --approval-rule-template-name 1-approval-rule-for-all pull requests
```
輸出：  

```
{
    "disassociatedRepositoryNames": [
        "MyDemoRepo",
        "MyOtherDemoRepo"
    ],
    "errors": []
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[取消與核准規則範本的關聯](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-disassociate-template.html#batch-disassociate-template)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [BatchDisassociateApprovalRuleTemplateFromRepositories](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/batch-disassociate-approval-rule-template-from-repositories.html)。

### `batch-get-commits`
<a name="codecommit_BatchGetCommits_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-get-commits`。

**AWS CLI**  
**檢視多個遞交的相關資訊**  
下列 `batch-get-commits` 範例顯示指定遞交的詳細資訊。  

```
aws codecommit batch-get-commits  \
    --repository-name MyDemoRepo  \
    --commit-ids 317f8570EXAMPLE 4c925148EXAMPLE
```
輸出：  

```
{
    "commits": [
      {
        "additionalData": "",
        "committer": {
            "date": "1508280564 -0800",
            "name": "Mary Major",
            "email": "mary_major@example.com"
        },
        "author": {
            "date": "1508280564 -0800",
            "name": "Mary Major",
            "email": "mary_major@example.com"
        },
        "commitId": "317f8570EXAMPLE",
        "treeId": "1f330709EXAMPLE",
        "parents": [
            "6e147360EXAMPLE"
        ],
        "message": "Change variable name and add new response element"
    },
    {
        "additionalData": "",
        "committer": {
            "date": "1508280542 -0800",
            "name": "Li Juan",
            "email": "li_juan@example.com"
        },
        "author": {
            "date": "1508280542 -0800",
            "name": "Li Juan",
            "email": "li_juan@example.com"
        },
        "commitId": "4c925148EXAMPLE",
        "treeId": "1f330709EXAMPLE",
        "parents": [
            "317f8570EXAMPLE"
        ],
        "message": "Added new class"
    }
}
```
如需詳細資訊，請參閱《AWS CodeCommit 使用者指南》**中的[檢視遞交詳細資訊](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-view-commit-details.html#how-to-view-commit-details-cli-batch-get-commits)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchGetCommits](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/batch-get-commits.html)。

### `batch-get-repositories`
<a name="codecommit_BatchGetRepositories_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-get-repositories`。

**AWS CLI**  
**檢視多個儲存庫的詳細資訊**  
此範例顯示多個 AWS CodeCommit 儲存庫的詳細資訊。  

```
aws codecommit batch-get-repositories \
    --repository-names MyDemoRepo MyOtherDemoRepo
```
輸出：  

```
{
    "repositoriesNotFound": [],
    "repositories": [
         {
            "creationDate": 1429203623.625,
            "defaultBranch": "main",
            "repositoryName": "MyDemoRepo",
            "cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo",
            "lastModifiedDate": 1430783812.0869999,
            "repositoryDescription": "My demonstration repository",
            "cloneUrlHttp": "https://codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo",
            "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
            "Arn": "arn:aws:codecommit:us-east-2:111111111111:MyDemoRepo"
            "accountId": "111111111111"
        },
        {
            "creationDate": 1429203623.627,
            "defaultBranch": "main",
            "repositoryName": "MyOtherDemoRepo",
            "cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyOtherDemoRepo",
            "lastModifiedDate": 1430783812.0889999,
            "repositoryDescription": "My other demonstration repository",
            "cloneUrlHttp": "https://codecommit.us-east-2.amazonaws.com/v1/repos/MyOtherDemoRepo",
            "repositoryId": "cfc29ac4-b0cb-44dc-9990-f6f51EXAMPLE",
            "Arn": "arn:aws:codecommit:us-east-2:111111111111:MyOtherDemoRepo"
            "accountId": "111111111111"
        }
    ],
    "repositoriesNotFound": []
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchGetRepositories](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/batch-get-repositories.html)。

### `create-approval-rule-template`
<a name="codecommit_CreateApprovalRuleTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-approval-rule-template`。

**AWS CLI**  
**建立核准規則範本**  
下列 `create-approval-rule-template` 範例建立名為 `2-approver-rule-for-main ``. The template requires two users who assume the role of ``CodeCommitReview` 的核准規則範本，以核准任何提取請求後，再合併到 `main` 分支。  

```
aws codecommit create-approval-rule-template \
    --approval-rule-template-name 2-approver-rule-for-main \
    --approval-rule-template-description  "Requires two developers from the team to approve the pull request if the destination branch is main" \
    --approval-rule-template-content "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}"
```
輸出：  

```
{
    "approvalRuleTemplate": {
        "approvalRuleTemplateName": "2-approver-rule-for-main",
        "creationDate": 1571356106.936,
        "approvalRuleTemplateId": "dd8b17fe-EXAMPLE",
        "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
        "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
        "approvalRuleTemplateDescription": "Requires two developers from the team to approve the pull request if the destination branch is main",
        "lastModifiedDate": 1571356106.936,
        "ruleContentSha256": "4711b576EXAMPLE"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[建立核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-template.html#create-template-cli)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateApprovalRuleTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-approval-rule-template.html)。

### `create-branch`
<a name="codecommit_CreateBranch_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-branch`。

**AWS CLI**  
**建立分支**  
此範例會在 AWS CodeCommit 儲存庫中建立分支。只有在發生錯誤時，此命令才會產生輸出。  
命令：  

```
aws codecommit create-branch --repository-name MyDemoRepo --branch-name MyNewBranch --commit-id 317f8570EXAMPLE
```
輸出：  

```
None.
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateBranch](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-branch.html)。

### `create-commit`
<a name="codecommit_CreateCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-commit`。

**AWS CLI**  
**建立遞交**  
下列 `create-commit` 範例展示如何為將 `readme.md` 檔案新增至 `main` 分支中名為 `MyDemoRepo` 的儲存庫，建立初始遞交。  

```
aws codecommit create-commit \
    --repository-name MyDemoRepo \
    --branch-name main \
    --put-files "filePath=readme.md,fileContent='Welcome to our team repository.'"
```
輸出：  

```
{
    "filesAdded": [
        {
            "blobId": "5e1c309d-EXAMPLE",
            "absolutePath": "readme.md",
            "fileMode": "NORMAL"
        }
    ],
    "commitId": "4df8b524-EXAMPLE",
    "treeId": "55b57003-EXAMPLE",
    "filesDeleted": [],
    "filesUpdated": []
}
```
如需詳細資訊，請參閱 [CodeCommit 使用者指南中的在 AWS CodeCommit 中建立](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-commit.html#how-to-create-commit-cli)遞交。 *AWS CodeCommit *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-commit.html)。

### `create-pull-request-approval-rule`
<a name="codecommit_CreatePullRequestApprovalRule_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-pull-request-approval-rule`。

**AWS CLI**  
**建立提取請求的核准規則**  
下列 `create-pull-request-approval-rule` 範例針對指定的提取請求，建立名為 `Require two approved approvers` 的核准規則。此規則指定需要有來自核准集區的兩個核准。集區包含透過`CodeCommitReview`在`123456789012` AWS 帳戶中擔任 角色來存取 CodeCommit 的所有使用者。它還包含`Nikhil_Jayashankar`來自相同 AWS 帳戶的 IAM 使用者或名為 的聯合身分使用者。  

```
aws codecommit create-pull-request-approval-rule  \
    --approval-rule-name "Require two approved approvers"  \
    --approval-rule-content "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"CodeCommitApprovers:123456789012:Nikhil_Jayashankar\", \"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}"
```
輸出：  

```
{
    "approvalRule": {
        "approvalRuleName": "Require two approved approvers",
        "lastModifiedDate": 1570752871.932,
        "ruleContentSha256": "7c44e6ebEXAMPLE",
        "creationDate": 1570752871.932,
        "approvalRuleId": "aac33506-EXAMPLE",
        "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"CodeCommitApprovers:123456789012:Nikhil_Jayashankar\", \"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
        "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[建立核准規則](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-pull-request-approval-rule.html#how-to-create-pull-request-approval-rule-cli)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreatePullRequestApprovalRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-pull-request-approval-rule.html)。

### `create-pull-request`
<a name="codecommit_CreatePullRequest_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-pull-request`。

**AWS CLI**  
**建立提取請求**  
下列`create-pull-request`範例會建立名為「發音困難分析器」的提取請求，其描述為「請檢閱週二的這些變更，該變更以「jane-branch」來源分支為目標，並將合併到名為「MyDemoRepo」的 AWS CodeCommit 儲存庫中的預設分支「主要」。  

```
aws codecommit create-pull-request \
    --title "My Pull Request" \
    --description "Please review these changes by Tuesday" \
    --client-request-token 123Example \
    --targets repositoryName=MyDemoRepo,sourceReference=MyNewBranch
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approver-rule-for-main",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "originApprovalRuleTemplate": {
                    "approvalRuleTemplateId": "dd3d22fe-EXAMPLE",
                    "approvalRuleTemplateName": "2-approver-rule-for-main"
                },
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::111111111111:user/Jane_Doe",
        "description": "Please review these changes by Tuesday",
        "title": "Pronunciation difficulty analyzer",
        "pullRequestTargets": [
            {
                "destinationCommit": "5d036259EXAMPLE",
                "destinationReference": "refs/heads/main",
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "317f8570EXAMPLE",
                "sourceReference": "refs/heads/jane-branch",
                "mergeMetadata": {
                    "isMerged": false
                }
            }
        ],
        "lastActivityDate": 1508962823.285,
        "pullRequestId": "42",
        "clientRequestToken": "123Example",
        "pullRequestStatus": "OPEN",
        "creationDate": 1508962823.285
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreatePullRequest](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-pull-request.html)。

### `create-repository`
<a name="codecommit_CreateRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-repository`。

**AWS CLI**  
**建立儲存庫**  
此範例會建立儲存庫，並將其與使用者帳戶建立關聯 AWS 。  
命令：  

```
aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository"
```
輸出：  

```
{
    "repositoryMetadata": {
        "repositoryName": "MyDemoRepo",
                "cloneUrlSsh": "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
                "lastModifiedDate": 1444766838.027,
        "repositoryDescription": "My demonstration repository",
                "cloneUrlHttp": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
        "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
                "Arn": "arn:aws:codecommit:us-east-1:111111111111EXAMPLE:MyDemoRepo",
        "accountId": "111111111111"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-repository.html)。

### `create-unreferenced-merge-commit`
<a name="codecommit_CreateUnreferencedMergeCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-unreferenced-merge-commit`。

**AWS CLI**  
**建立一個未參照遞交，其代表合併兩個遞交指標的結果**  
下列 `create-unreferenced-merge-commit` 範例建立一個遞交，其代表在名為 `MyDemoRepo` 的儲存庫中，使用 THREE\$1WAY\$1MERGE 策略對名為 `bugfix-1234` 的來源分支，與名為 `main` 的目標分支進行合併的結果。  

```
aws codecommit create-unreferenced-merge-commit \
    --source-commit-specifier bugfix-1234 \
    --destination-commit-specifier main \
    --merge-option THREE_WAY_MERGE \
    --repository-name MyDemoRepo \
    --name "Maria Garcia" \
    --email "maria_garcia@example.com" \
    --commit-message "Testing the results of this merge."
```
輸出：  

```
{
    "commitId": "4f178133EXAMPLE",
    "treeId": "389765daEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[解決提取請求中的衝突](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-resolve-conflict-pull-request.html#batch-describe-merge-conflicts)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateUnreferencedMergeCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/create-unreferenced-merge-commit.html)。

### `credential-helper`
<a name="codecommit_CredentialHelper_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `credential-helper`。

**AWS CLI**  
**使用 AWS CodeCommit 設定 CLI AWS 中包含的登入資料協助程式**  
`credential-helper` 公用程式的設計並非直接從 CLI AWS 呼叫。反之，該公用程式旨在搭配 `git config` 命令當作參數使用，以設定您的本機電腦。每當 Git 需要向 驗證 AWS 才能與 CodeCommit 儲存庫互動時，它可讓 Git 使用 HTTPS 和密碼編譯簽署的 IAM 使用者憑證或 Amazon EC2 執行個體角色版本。  

```
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
```
輸出：  

```
[credential]
    helper = !aws codecommit credential-helper $@
    UseHttpPath = true
```
如需詳細資訊，請參閱 AWS CodeCommit 使用者指南中的*AWS 使用其他方法設定 CodeCommit*。仔細檢閱內容，然後遵循下列其中一個主題中的程序：適用於 Linux、macOS 或 Unix 上的 HTTPS 連線，或《*AWS CodeCommit 使用者指南*》中適用於 Windows 的 HTTPS 連線。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CredentialHelper](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/credential-helper.html)。

### `delete-approval-rule-template`
<a name="codecommit_DeleteApprovalRuleTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-approval-rule-template`。

**AWS CLI**  
**刪除核准規則範本**  
以下 `delete-approval-rule-template` 範例會刪除指定的核准規則範本。  

```
aws codecommit delete-approval-rule-template  \
    --approval-rule-template-name 1-approver-for-all-pull-requests
```
輸出：  

```
{
    "approvalRuleTemplateId": "41de97b7-EXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[刪除核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-delete-template.html#delete-template)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteApprovalRuleTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-approval-rule-template.html)。

### `delete-branch`
<a name="codecommit_DeleteBranch_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-branch`。

**AWS CLI**  
**刪除分支**  
此範例說明如何刪除 AWS CodeCommit 儲存庫中的分支。  
命令：  

```
aws codecommit delete-branch --repository-name MyDemoRepo --branch-name MyNewBranch
```
輸出：  

```
{
  "branch": {
      "commitId": "317f8570EXAMPLE",
      "branchName": "MyNewBranch"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteBranch](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-branch.html)。

### `delete-comment-content`
<a name="codecommit_DeleteCommentContent_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-comment-content`。

**AWS CLI**  
**刪除評論的內容**  
您只能刪除您所建立評論的評論內容。此範例展示如何使用系統產生的 ID `ff30b348EXAMPLEb9aa670f` 刪除評論的內容。  

```
aws codecommit delete-comment-content \
    --comment-id ff30b348EXAMPLEb9aa670f
```
輸出：  

```
{
    "comment": {
        "creationDate": 1508369768.142,
        "deleted": true,
        "lastModifiedDate": 1508369842.278,
        "clientRequestToken": "123Example",
        "commentId": "ff30b348EXAMPLEb9aa670f",
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "callerReactions": [],
        "reactionCounts":
        {
            "CLAP" : 1
        }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteCommentContent](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-comment-content.html)。

### `delete-file`
<a name="codecommit_DeleteFile_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-file`。

**AWS CLI**  
**刪除檔案**  
下列 `delete-file` 範例展示如何從名為 `main` 的分支中，刪除名為 `README.md` 的檔案，而該分支在名為 `MyDemoRepo` 的儲存庫中具有 `c5709475EXAMPLE` 的最新遞交 ID。  

```
aws codecommit delete-file \
    --repository-name MyDemoRepo \
    --branch-name main \
    --file-path README.md \
    --parent-commit-id c5709475EXAMPLE
```
輸出：  

```
{
    "blobId":"559b44fEXAMPLE",
    "commitId":"353cf655EXAMPLE",
    "filePath":"README.md",
    "treeId":"6bc824cEXAMPLE"
}
```
如需詳細資訊，請參閱 [AWS CodeCommit API 參考指南中的編輯或刪除檔案 inCodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-edit-file.html?shortFooter=true#how-to-edit-file-cli)*AWS CodeCommit*。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteFile](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-file.html)。

### `delete-pull-request-approval-rule`
<a name="codecommit_DeletePullRequestApprovalRule_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-pull-request-approval-rule`。

**AWS CLI**  
**刪除提取請求的核准規則**  
下列 `delete-pull-request-approval-rule` 範例刪除指定提取請求之名為 `My Approval Rule` 的核准規則。  

```
aws codecommit delete-pull-request-approval-rule  \
    --approval-rule-name "My Approval Rule"  \
    --pull-request-id 15
```
輸出：  

```
{
    "approvalRuleId": "077d8e8a8-EXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[編輯或刪除核准規則](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-edit-delete-pull-request-approval-rule.html#delete-pull-request-approval-rule)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeletePullRequestApprovalRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-pull-request-approval-rule.html)。

### `delete-repository`
<a name="codecommit_DeleteRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-repository`。

**AWS CLI**  
**刪除儲存庫**  
此範例示範如何刪除 AWS CodeCommit 儲存庫。  
命令：  

```
aws codecommit delete-repository --repository-name MyDemoRepo
```
輸出：  

```
{
  "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/delete-repository.html)。

### `describe-merge-conflicts`
<a name="codecommit_DescribeMergeConflicts_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-merge-conflicts`。

**AWS CLI**  
**取得合併衝突的詳細資訊**  
下列 `describe-merge-conflicts` 範例使用 THREE\$1WAY\$1MERGE 策略，判斷指定來源分支和目的地分支中，名為 `readme.md` 之檔案的合併衝突。  

```
aws codecommit describe-merge-conflicts \
    --source-commit-specifier feature-randomizationfeature \
    --destination-commit-specifier main \
    --merge-option THREE_WAY_MERGE \
    --file-path readme.md \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "conflictMetadata": {
        "filePath": "readme.md",
        "fileSizes": {
            "source": 139,
            "destination": 230,
            "base": 85
        },
        "fileModes": {
            "source": "NORMAL",
            "destination": "NORMAL",
            "base": "NORMAL"
        },
        "objectTypes": {
            "source": "FILE",
            "destination": "FILE",
            "base": "FILE"
        },
        "numberOfConflicts": 1,
        "isBinaryFile": {
            "source": false,
            "destination": false,
            "base": false
        },
        "contentConflict": true,
        "fileModeConflict": false,
        "objectTypeConflict": false,
        "mergeOperations": {
            "source": "M",
            "destination": "M"
        }
    },
    "mergeHunks": [
        {
            "isConflict": true,
            "source": {
                "startLine": 0,
                "endLine": 3,
                "hunkContent": "VGhpcyBpEXAMPLE="
            },
            "destination": {
                "startLine": 0,
                "endLine": 1,
                "hunkContent": "VXNlIHRoEXAMPLE="
            }
        }
    ],
    "destinationCommitId": "86958e0aEXAMPLE",
    "sourceCommitId": "6ccd57fdEXAMPLE",
    "baseCommitId": "767b69580EXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[解決提取請求中的衝突](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-resolve-conflict-pull-request.html#describe-merge-conflicts)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeMergeConflicts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/describe-merge-conflicts.html)。

### `describe-pull-request-events`
<a name="codecommit_DescribePullRequestEvents_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-pull-request-events`。

**AWS CLI**  
**檢視提取請求中的事件**  
下列 `describe-pull-request-events` 範例擷取 ID 為 '8' 之提取請求的事件。  

```
aws codecommit describe-pull-request-events --pull-request-id 8
```
輸出：  

```
{
    "pullRequestEvents": [
        {
            "pullRequestId": "8",
            "pullRequestEventType": "PULL_REQUEST_CREATED",
            "eventDate": 1510341779.53,
            "actor": "arn:aws:iam::111111111111:user/Zhang_Wei"
        },
        {
            "pullRequestStatusChangedEventMetadata": {
                "pullRequestStatus": "CLOSED"
            },
            "pullRequestId": "8",
            "pullRequestEventType": "PULL_REQUEST_STATUS_CHANGED",
            "eventDate": 1510341930.72,
            "actor": "arn:aws:iam::111111111111:user/Jane_Doe"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribePullRequestEvents](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/describe-pull-request-events.html)。

### `disassociate-approval-rule-template-from-repository`
<a name="codecommit_DisassociateApprovalRuleTemplateFromRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `disassociate-approval-rule-template-from-repository`。

**AWS CLI**  
**取消核准規則範本與儲存庫的關聯**  
下列 `disassociate-approval-rule-template-from-repository` 範例取消指定的核准規則範本，與名為 `MyDemoRepo` 的儲存庫的關聯。  

```
aws codecommit disassociate-approval-rule-template-from-repository \
    --repository-name MyDemoRepo  \
    --approval-rule-template-name 1-approver-rule-for-all-pull-requests
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[取消與核准規則範本的關聯](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-disassociate-template.html#disassociate-template)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [DisassociateApprovalRuleTemplateFromRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/disassociate-approval-rule-template-from-repository.html)。

### `evaluate-pull-request-approval-rules`
<a name="codecommit_EvaluatePullRequestApprovalRules_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `evaluate-pull-request-approval-rules`。

**AWS CLI**  
**評估提取請求是否符合其所有核准規則**  
下列 `evaluate-pull-request-approval-rules` 範例會評估指定提取請求的核准規則狀態。在此範例中，提取請求尚未符合核准規則，因此命令的輸出會顯示 `approved` 的值 `false`。  

```
aws codecommit evaluate-pull-request-approval-rules \
    --pull-request-id 27  \
    --revision-id 9f29d167EXAMPLE
```
輸出：  

```
{
    "evaluation": {
        "approved": false,
        "approvalRulesNotSatisfied": [
            "Require two approved approvers"
        ],
        "overridden": false,
        "approvalRulesSatisfied": []
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[合併提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-merge-pull-request.html#evaluate-pull-request-approval-rules)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [EvaluatePullRequestApprovalRules](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/evaluate-pull-request-approval-rules.html)。

### `get-approval-rule-template`
<a name="codecommit_GetApprovalRuleTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-approval-rule-template`。

**AWS CLI**  
**取得核准規則範本的內容**  
下列 `get-approval-rule-template` 範例取得名為 `1-approver-rule-for-all-pull-requests` 的核准規則範本內容。  

```
aws codecommit get-approval-rule-template \
    --approval-rule-template-name 1-approver-rule-for-all-pull-requests
```
輸出：  

```
{
    "approvalRuleTemplate": {
        "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
        "ruleContentSha256": "621181bbEXAMPLE",
        "lastModifiedDate": 1571356106.936,
        "creationDate": 1571356106.936,
        "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
        "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan",
        "approvalRuleTemplateId": "a29abb15-EXAMPLE",
        "approvalRuleTemplateDescription": "All pull requests must be approved by one developer on the team."
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#get-template)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApprovalRuleTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-approval-rule-template.html)。

### `get-blob`
<a name="codecommit_GetBlob_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-blob`。

**AWS CLI**  
**檢視 Git Blob 物件的詳細資訊**  
下列`get-blob`範例會在名為 'MyDemoRepo' 的CodeCommit 儲存庫中，擷取 ID 為 '2eb4af3bEXAMPLE' 的 Git Blob 相關資訊。 AWS CodeCommit   

```
aws codecommit get-blob  --repository-name MyDemoRepo  --blob-id 2eb4af3bEXAMPLE
```
輸出：  

```
{
    "content": "QSBCaW5hcnkgTGFyToEXAMPLE="
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetBlob](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-blob.html)。

### `get-branch`
<a name="codecommit_GetBranch_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-branch`。

**AWS CLI**  
**取得分支的相關資訊**  
此範例會取得 AWS CodeCommit 儲存庫中分支的相關資訊。  
命令：  

```
aws codecommit get-branch --repository-name MyDemoRepo --branch-name MyNewBranch
```
輸出：  

```
{
  "BranchInfo": {
        "commitID": "317f8570EXAMPLE",
                "branchName": "MyNewBranch"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetBranch](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-branch.html)。

### `get-comment-reactions`
<a name="codecommit_GetCommentReactions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-comment-reactions`。

**AWS CLI**  
**檢視對註解的表情符號反應**  
下列 `get-comment-reactions` 範例列出 ID 為 `abcd1234EXAMPLEb5678efgh` 之評論的所有表情符號反應。如果您的 shell 字型支援顯示表情符號 1.0 版，則會在 `emoji` 表情符號的輸出中顯示 。  

```
aws codecommit get-comment-reactions \
    --comment-id abcd1234EXAMPLEb5678efgh
```
輸出：  

```
{
    "reactionsForComment": {
        [
           {
               "reaction": {
                    "emoji:"??",
                    "shortCode": "thumbsup",
                    "unicode": "U+1F44D"
                },
                "users": [
                    "arn:aws:iam::123456789012:user/Li_Juan",
                    "arn:aws:iam::123456789012:user/Mary_Major",
                    "arn:aws:iam::123456789012:user/Jorge_Souza"
                ]
            },
            {
                "reaction": {
                    "emoji": "??",
                    "shortCode": "thumbsdown",
                    "unicode": "U+1F44E"
                },
                "users": [
                    "arn:aws:iam::123456789012:user/Nikhil_Jayashankar"
                ]
            },
            {
                "reaction": {
                    "emoji": "??",
                    "shortCode": "confused",
                    "unicode": "U+1F615"
                },
                "users": [
                    "arn:aws:iam::123456789012:user/Saanvi_Sarkar"
                ]
            }
        ]
    }
}
```
如需詳細資訊，請參閱 [AWS CodeCommit 使用者指南中的對遞交 inCodeCommit 的註解](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-commit-comment.html#how-to-commit-comment-cli-commit-emoji-view)。 *AWS CodeCommit *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetCommentReactions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-comment-reactions.html)。

### `get-comment`
<a name="codecommit_GetComment_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-comment`。

**AWS CLI**  
**檢視評論的詳細資訊**  
此範例展示如何使用系統產生的評論 ID `ff30b348EXAMPLEb9aa670f` 檢視評論的詳細資訊。  

```
aws codecommit get-comment \
    --comment-id ff30b348EXAMPLEb9aa670f
```
輸出：  

```
{
    "comment": {
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "clientRequestToken": "123Example",
        "commentId": "ff30b348EXAMPLEb9aa670f",
        "content": "Whoops - I meant to add this comment to the line, but I don't see how to delete it.",
        "creationDate": 1508369768.142,
        "deleted": false,
        "commentId": "",
        "lastModifiedDate": 1508369842.278,
        "callerReactions": [],
        "reactionCounts":
        {
            "SMILE" : 6,
            "THUMBSUP" : 1
        }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetComment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-comment.html)。

### `get-comments-for-compared-commit`
<a name="codecommit_GetCommentsForComparedCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-comments-for-compared-commit`。

**AWS CLI**  
**檢視對遞交的評論**  
此範例展示如何檢視名為 `MyDemoRepo` 的儲存庫中兩個遞交之間的比較所做的評論。  

```
aws codecommit get-comments-for-compared-commit \
    --repository-name MyDemoRepo \
    --before-commit-ID 6e147360EXAMPLE \
    --after-commit-id 317f8570EXAMPLE
```
輸出：  

```
{
    "commentsForComparedCommitData": [
        {
            "afterBlobId": "1f330709EXAMPLE",
            "afterCommitId": "317f8570EXAMPLE",
            "beforeBlobId": "80906a4cEXAMPLE",
            "beforeCommitId": "6e147360EXAMPLE",
            "comments": [
                {
                    "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                    "clientRequestToken": "123Example",
                    "commentId": "ff30b348EXAMPLEb9aa670f",
                    "content": "Whoops - I meant to add this comment to the line, not the file, but I don't see how to delete it.",
                    "creationDate": 1508369768.142,
                    "deleted": false,
                    "CommentId": "123abc-EXAMPLE",
                    "lastModifiedDate": 1508369842.278,
                    "callerReactions": [],
                    "reactionCounts":
                    {
                        "SMILE" : 6,
                        "THUMBSUP" : 1
                    }
                },
                {
                    "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                    "clientRequestToken": "123Example",
                    "commentId": "553b509bEXAMPLE56198325",
                    "content": "Can you add a test case for this?",
                    "creationDate": 1508369612.240,
                    "deleted": false,
                    "commentId": "456def-EXAMPLE",
                    "lastModifiedDate": 1508369612.240,
                    "callerReactions": [],
                    "reactionCounts":
                    {
                        "THUMBSUP" : 2
                    }
                }
            ],
            "location": {
                "filePath": "cl_sample.js",
                "filePosition": 1232,
                "relativeFileVersion": "after"
            },
            "repositoryName": "MyDemoRepo"
        }
    ],
    "nextToken": "exampleToken"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetCommentsForComparedCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-comments-for-compared-commit.html)。

### `get-comments-for-pull-request`
<a name="codecommit_GetCommentsForPullRequest_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-comments-for-pull-request`。

**AWS CLI**  
**檢視提取請求的評論**  
此範例展示如何檢視對名為 `MyDemoRepo` 的儲存庫中提取請求的評論：  

```
aws codecommit get-comments-for-pull-request \
    --repository-name MyDemoRepo \
    --before-commit-ID 317f8570EXAMPLE \
    --after-commit-id 5d036259EXAMPLE
```
輸出：  

```
{
    "commentsForPullRequestData": [
        {
            "afterBlobId": "1f330709EXAMPLE",
            "afterCommitId": "5d036259EXAMPLE",
            "beforeBlobId": "80906a4cEXAMPLE",
            "beforeCommitId": "317f8570EXAMPLE",
            "comments": [
                {
                    "authorArn": "arn:aws:iam::111111111111:user/Saanvi_Sarkar",
                    "clientRequestToken": "",
                    "commentId": "abcd1234EXAMPLEb5678efgh",
                    "content": "These don't appear to be used anywhere. Can we remove them?",
                    "creationDate": 1508369622.123,
                    "deleted": false,
                    "lastModifiedDate": 1508369622.123,
                    "callerReactions": [],
                    "reactionCounts":
                    {
                        "THUMBSUP" : 6,
                        "CONFUSED" : 1
                    }
                },
                {
                    "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
                    "clientRequestToken": "",
                    "commentId": "442b498bEXAMPLE5756813",
                    "content": "Good catch. I'll remove them.",
                    "creationDate": 1508369829.104,
                    "deleted": false,
                    "lastModifiedDate": 150836912.273,
                    "callerReactions": ["THUMBSUP"]
                    "reactionCounts":
                    {
                        "THUMBSUP" : 14
                    }
                }
            ],
            "location": {
                "filePath": "ahs_count.py",
                "filePosition": 367,
                "relativeFileVersion": "AFTER"
            },
            "repositoryName": "MyDemoRepo",
            "pullRequestId": "42"
        }
    ],
    "nextToken": "exampleToken"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetCommentsForPullRequest](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-comments-for-pull-request.html)。

### `get-commit`
<a name="codecommit_GetCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-commit`。

**AWS CLI**  
**檢視儲存庫中的遞交相關資訊**  
此範例顯示在名為 'MyDemoRepo' 的 AWS CodeCommit 儲存庫中，系統產生 ID 為 '7e9fd3091thisisanexamplethisisanexample1' 的遞交詳細資訊。  
命令：  

```
aws codecommit get-commit --repository-name MyDemoRepo --commit-id 7e9fd3091thisisanexamplethisisanexample1
```
輸出：  

```
{
  "commit": {
      "additionalData": "",
      "committer": {
          "date": "1484167798 -0800",
          "name": "Mary Major",
          "email": "mary_major@example.com"
      },
      "author": {
          "date": "1484167798 -0800",
          "name": "Mary Major",
          "email": "mary_major@example.com"
      },
      "treeId": "347a3408thisisanexampletreeidexample",
      "parents": [
          "7aa87a031thisisanexamplethisisanexample1"
      ],
      "message": "Fix incorrect variable name"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-commit.html)。

### `get-differences`
<a name="codecommit_GetDifferences_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-differences`。

**AWS CLI**  
**取得儲存庫中遞交指標差異的相關資訊**  
此範例顯示在 AWS CodeCommit 名為 MyDemoRepo 的重新命名資料夾中，檢視兩個遞交指標 （分支、標籤、HEAD 或其他完整參考，例如遞交 IDs) 之間變更的中繼資料資訊。此範例包含幾個不需要的選項，包括 --before-commit-specifier、--before-path 和 --after-path，以便更完整地說明如何使用這些選項來限制結果。回應包含檔案模式許可。  
命令：  

```
aws codecommit get-differences --repository-name MyDemoRepo --before-commit-specifier 955bba12thisisanexamplethisisanexample --after-commit-specifier 14a95463thisisanexamplethisisanexample --before-path tmp/example-folder --after-path tmp/renamed-folder
```
輸出：  

```
{
  "differences": [
      {
          "afterBlob": {
              "path": "blob.txt",
              "blobId": "2eb4af3b1thisisanexamplethisisanexample1",
              "mode": "100644"
          },
          "changeType": "M",
          "beforeBlob": {
              "path": "blob.txt",
              "blobId": "bf7fcf281thisisanexamplethisisanexample1",
              "mode": "100644"
          }
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDifferences](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-differences.html)。

### `get-file`
<a name="codecommit_GetFile_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-file`。

**AWS CLI**  
**取得 AWS CodeCommit 儲存庫中檔案的 base-64 編碼內容**  
下列 `get-file` 範例展示如何從名為 `MyDemoRepo` 的儲存庫中，名為 `main` 的分支取得名為 `README.md` 之檔案的 base-64 編碼內容。  

```
aws codecommit get-file \
    --repository-name MyDemoRepo \
    --commit-specifier main \
    --file-path README.md
```
輸出：  

```
{
    "blobId":"559b44fEXAMPLE",
    "commitId":"c5709475EXAMPLE",
    "fileContent":"IyBQaHVzEXAMPLE",
    "filePath":"README.md",
    "fileMode":"NORMAL",
    "fileSize":1563
}
```
如需詳細資訊，請參閱《*AWS CodeCommit API 參考*指南》中的 [GetFile](https://docs.aws.amazon.com/codecommit/latest/APIReference/API_GetFile.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetFile](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-file.html)。

### `get-folder`
<a name="codecommit_GetFolder_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-folder`。

**AWS CLI**  
**取得 AWS CodeCommit 儲存庫中資料夾的內容**  
下列 `get-folder` 範例展示如何從名為 `MyDemoRepo` 的儲存庫取得最上層資料夾的內容。  

```
aws codecommit get-folder --repository-name MyDemoRepo --folder-path ""
```
輸出：  

```
{
    "commitId":"c5709475EXAMPLE",
    "files":[
        {
            "absolutePath":".gitignore",
            "blobId":"74094e8bEXAMPLE",
            "fileMode":"NORMAL",
            "relativePath":".gitignore"
        },
        {
            "absolutePath":"Gemfile",
            "blobId":"9ceb72f6EXAMPLE",
            "fileMode":"NORMAL",
            "relativePath":"Gemfile"
        },
        {
            "absolutePath":"Gemfile.lock",
            "blobId":"795c4a2aEXAMPLE",
            "fileMode":"NORMAL",
            "relativePath":"Gemfile.lock"
        },
        {
            "absolutePath":"LICENSE.txt",
            "blobId":"0c7932c8EXAMPLE",
            "fileMode":"NORMAL",
            "relativePath":"LICENSE.txt"
        },
        {
            "absolutePath":"README.md",
            "blobId":"559b44feEXAMPLE",
            "fileMode":"NORMAL",
            "relativePath":"README.md"
        }
    ],
    "folderPath":"",
    "subFolders":[
        {
            "absolutePath":"public",
            "relativePath":"public",
            "treeId":"d5e92ae3aEXAMPLE"
        },
        {
            "absolutePath":"tmp",
            "relativePath":"tmp",
            "treeId":"d564d0bcEXAMPLE"
        }
    ],
    "subModules":[],
    "symbolicLinks":[],
    "treeId":"7b3c4dadEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit API 參考*指南》中的 GetFolder。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetFolder](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-folder.html)。

### `get-merge-commit`
<a name="codecommit_GetMergeCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-merge-commit`。

**AWS CLI**  
**取得合併遞交的詳細資訊**  
下列 `get-merge-commit` 範例顯示，在名為 `MyDemoRepo` 儲存庫中名為 `bugfix-bug1234` 的來源分支，與名為 `main` 的目的地分支之合併遞交的詳細資訊。  

```
aws codecommit get-merge-commit \
    --source-commit-specifier bugfix-bug1234 \
    --destination-commit-specifier main \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "sourceCommitId": "c5709475EXAMPLE",
    "destinationCommitId": "317f8570EXAMPLE",
    "baseCommitId": "fb12a539EXAMPLE",
    "mergeCommitId": "ffc4d608eEXAMPLE"
}
```
如需詳細資訊，請參閱《AWS CodeCommit 使用者指南》**中的[檢視遞交詳細資訊](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-view-commit-details.html#how-to-view-commit-details-cli-merge-commit)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetMergeCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-merge-commit.html)。

### `get-merge-conflicts`
<a name="codecommit_GetMergeConflicts_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-merge-conflicts`。

**AWS CLI**  
**檢視提取請求是否有任何合併衝突**  
下列 `get-merge-conflicts` 範例顯示，在名為 `MyDemoRepo` 儲存庫中名為 `feature-randomizationfeature` 的來源分支尖端，與名為 'main' 的目的地分支之間，是否有任何合併衝突。  

```
aws codecommit get-merge-conflicts \
    --repository-name MyDemoRepo \
    --source-commit-specifier feature-randomizationfeature \
    --destination-commit-specifier main \
    --merge-option THREE_WAY_MERGE
```
輸出：  

```
{
    "mergeable": false,
    "destinationCommitId": "86958e0aEXAMPLE",
    "sourceCommitId": "6ccd57fdEXAMPLE",
    "baseCommitId": "767b6958EXAMPLE",
    "conflictMetadataList": [
        {
            "filePath": "readme.md",
            "fileSizes": {
                "source": 139,
                "destination": 230,
                "base": 85
            },
            "fileModes": {
                "source": "NORMAL",
                "destination": "NORMAL",
                "base": "NORMAL"
            },
            "objectTypes": {
                "source": "FILE",
                "destination": "FILE",
                "base": "FILE"
            },
            "numberOfConflicts": 1,
            "isBinaryFile": {
                "source": false,
                "destination": false,
                "base": false
            },
            "contentConflict": true,
            "fileModeConflict": false,
            "objectTypeConflict": false,
            "mergeOperations": {
                "source": "M",
                "destination": "M"
            }
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetMergeConflicts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-merge-conflicts.html)。

### `get-merge-options`
<a name="codecommit_GetMergeOptions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-merge-options`。

**AWS CLI**  
**取得可用於合併兩個指定分支之合併選項的相關資訊**  
下列 `get-merge-options` 範例判定可用於合併名為 `MyDemoRepo` 的儲存庫中，名為 `bugfix-bug1234` 的來源分支與名為 `main` 的目的地分支的合併選項。  

```
aws codecommit get-merge-options \
    --source-commit-specifier bugfix-bug1234 \
    --destination-commit-specifier main \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "mergeOptions": [
        "FAST_FORWARD_MERGE",
        "SQUASH_MERGE",
        "THREE_WAY_MERGE"
    ],
    "sourceCommitId": "18059494EXAMPLE",
    "destinationCommitId": "ffd3311dEXAMPLE",
    "baseCommitId": "ffd3311dEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[解決提取請求中的衝突](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-resolve-conflict-pull-request.html#get-merge-options)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetMergeOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-merge-options.html)。

### `get-pull-request-approval-states`
<a name="codecommit_GetPullRequestApprovalStates_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-pull-request-approval-states`。

**AWS CLI**  
**檢視對提取請求的核准**  
下列 `get-pull-request-approval-states` 範例傳回對指定提取請求的核准。  

```
aws codecommit get-pull-request-approval-states \
    --pull-request-id 8 \
    --revision-id 9f29d167EXAMPLE
```
輸出：  

```
{
    "approvals": [
        {
            "userArn": "arn:aws:iam::123456789012:user/Mary_Major",
            "approvalState": "APPROVE"
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[檢視提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-view-pull-request.html#get-pull-request-approval-state)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI API 參考*》中的 [GetPullRequestApprovalStates](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-pull-request-approval-states.html)。

### `get-pull-request-override-state`
<a name="codecommit_GetPullRequestOverrideState_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-pull-request-override-state`。

**AWS CLI**  
**取得提取請求之覆寫狀態的相關資訊**  
下列 `get-pull-request-override-state` 範例傳回指定提取請求的覆寫狀態。在此範例中，對提取請求的核准規則已由名為 Mary Major 的使用者覆寫，因此輸出傳回值 `true`：  

```
aws codecommit get-pull-request-override-state \
    --pull-request-id 34  \
    --revision-id 9f29d167EXAMPLE
```
輸出：  

```
{
    "overridden": true,
    "overrider": "arn:aws:iam::123456789012:user/Mary_Major"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[覆寫提取請求的核准規則](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-override-approval-rules.html#get-override-status)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetPullRequestOverrideState](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-pull-request-override-state.html)。

### `get-pull-request`
<a name="codecommit_GetPullRequest_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-pull-request`。

**AWS CLI**  
**檢視提取請求的詳細資訊**  
此範例展示如何檢視 ID 為 `27` 之提取請求的相關資訊。  

```
aws codecommit get-pull-request \
    --pull-request-id 27
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approver-rule-for-main",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "lastActivityDate": 1562619583.565,
        "pullRequestTargets": [
            {
                "sourceCommit": "ca45e279EXAMPLE",
                "sourceReference": "refs/heads/bugfix-1234",
                "mergeBase": "a99f5ddbEXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": false
                },
                "destinationCommit": "2abfc6beEXAMPLE",
                "repositoryName": "MyDemoRepo"
            }
        ],
        "revisionId": "e47def21EXAMPLE",
        "title": "Quick fix for bug 1234",
        "authorArn": "arn:aws:iam::123456789012:user/Nikhil_Jayashankar",
        "clientRequestToken": "d8d7612e-EXAMPLE",
        "creationDate": 1562619583.565,
        "pullRequestId": "27",
        "pullRequestStatus": "OPEN"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetPullRequest](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-pull-request.html)。

### `get-repository-triggers`
<a name="codecommit_GetRepositoryTriggers_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-repository-triggers`。

**AWS CLI**  
**取得儲存庫中觸發程序的相關資訊**  
此範例顯示針對名為 的 AWS CodeCommit 儲存庫所設定的觸發詳細資訊`MyDemoRepo`。  

```
aws codecommit get-repository-triggers \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "configurationId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
    "triggers": [
        {
            "destinationArn": "arn:aws:sns:us-east-1:111111111111:MyCodeCommitTopic",
            "branches": [
                "main",
                "preprod"
            ],
            "name": "MyFirstTrigger",
            "customData": "",
            "events": [
                "all"
            ]
        },
        {
            "destinationArn": "arn:aws:lambda:us-east-1:111111111111:function:MyCodeCommitPythonFunction",
            "branches": [],
            "name": "MySecondTrigger",
            "customData": "EXAMPLE",
            "events": [
                "all"
            ]
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetRepositoryTriggers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-repository-triggers.html)。

### `get-repository`
<a name="codecommit_GetRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-repository`。

**AWS CLI**  
**取得儲存庫的相關資訊**  
此範例顯示有關 AWS CodeCommit 儲存庫的詳細資訊。  

```
aws codecommit get-repository \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "repositoryMetadata": {
        "creationDate": 1429203623.625,
        "defaultBranch": "main",
        "repositoryName": "MyDemoRepo",
        "cloneUrlSsh": "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/v1/repos/MyDemoRepo",
        "lastModifiedDate": 1430783812.0869999,
        "repositoryDescription": "My demonstration repository",
        "cloneUrlHttp": "https://codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
        "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
        "Arn": "arn:aws:codecommit:us-east-1:80398EXAMPLE:MyDemoRepo
        "accountId": "111111111111"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/get-repository.html)。

### `list-approval-rule-templates`
<a name="codecommit_ListApprovalRuleTemplates_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-approval-rule-templates`。

**AWS CLI**  
**列出 AWS 區域中的所有核准規則範本**  
下列 `list-approval-rule-templates` 範例列出指定區域中的所有核准規則範本。如果未將 AWS 區域指定為參數，則命令會傳回用於執行命令之 CLI AWS 設定檔中指定區域的核准規則範本。  

```
aws codecommit list-approval-rule-templates \
    --region us-east-2
```
輸出：  

```
{
    "approvalRuleTemplateNames": [
        "2-approver-rule-for-main",
        "1-approver-rule-for-all-pull-requests"
    ]
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#list-templates)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListApprovalRuleTemplates](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-approval-rule-templates.html)。

### `list-associated-approval-rule-templates-for-repository`
<a name="codecommit_ListAssociatedApprovalRuleTemplatesForRepository_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-associated-approval-rule-templates-for-repository`。

**AWS CLI**  
**列出與儲存庫相關聯的所有範本**  
下列 `list-associated-approval-rule-templates-for-repository` 範例列出與名為 `MyDemoRepo` 的儲存庫相關聯的所有核准規則範本。  

```
aws codecommit list-associated-approval-rule-templates-for-repository \
    --repository-name MyDemoRepo
```
輸出：  

```
{
  "approvalRuleTemplateNames": [
    "2-approver-rule-for-main",
    "1-approver-rule-for-all-pull-requests"
  ]
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#list-associated-templates)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [ListAssociatedApprovalRuleTemplatesForRepository](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-associated-approval-rule-templates-for-repository.html)。

### `list-branches`
<a name="codecommit_ListBranches_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-branches`。

**AWS CLI**  
**檢視分支名稱的清單**  
此範例會列出 AWS CodeCommit 儲存庫中的所有分支名稱。  

```
aws codecommit list-branches \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "branches": [
        "MyNewBranch",
        "main"
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListBranches](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-branches.html)。

### `list-pull-requests`
<a name="codecommit_ListPullRequests_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-pull-requests`。

**AWS CLI**  
**檢視儲存庫中的提取請求清單**  
此範例示範如何列出 ARN 為 'arn：aws：iam：：111111111111：user/Li\$1Juan' 的 IAM 使用者所建立的提取請求，以及名為 'MyDemoRepo' 的 AWS CodeCommit 儲存庫中的 'CLOSED' 狀態：  

```
aws codecommit list-pull-requests --author-arn arn:aws:iam::111111111111:user/Li_Juan --pull-request-status CLOSED --repository-name MyDemoRepo
```
輸出：  

```
{
 "nextToken": "",
 "pullRequestIds": ["2","12","16","22","23","35","30","39","47"]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListPullRequests](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-pull-requests.html)。

### `list-repositories-for-approval-rule-template`
<a name="codecommit_ListRepositoriesForApprovalRuleTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-repositories-for-approval-rule-template`。

**AWS CLI**  
**列出與範本相關聯的所有儲存庫**  
下列 `list-repositories-for-approval-rule-template` 範例列出與指定之核准規則範本相關聯的所有儲存庫。  

```
aws codecommit list-repositories-for-approval-rule-template \
    --approval-rule-template-name 2-approver-rule-for-main
```
輸出：  

```
{
    "repositoryNames": [
        "MyDemoRepo",
        "MyClonedRepo"
    ]
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#list-associated-repositories)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListRepositoriesForApprovalRuleTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-repositories-for-approval-rule-template.html)。

### `list-repositories`
<a name="codecommit_ListRepositories_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-repositories`。

**AWS CLI**  
**檢視儲存庫的清單**  
此範例列出與使用者帳戶相關聯的所有 AWS CodeCommit 儲存庫 AWS 。  
命令：  

```
aws codecommit list-repositories
```
輸出：  

```
{
  "repositories": [
      {
         "repositoryName": "MyDemoRepo"
         "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE",
      },
      {
         "repositoryName": "MyOtherDemoRepo"
         "repositoryId": "cfc29ac4-b0cb-44dc-9990-f6f51EXAMPLE"
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListRepositories](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-repositories.html)。

### `list-tags-for-resource`
<a name="codecommit_ListTagsForResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-tags-for-resource`。

**AWS CLI**  
**檢視儲存庫的 AWS 標籤**  
下列 `list-tags-for-resource` 範例列出指定之儲存庫的標籤鍵和標籤值。  

```
aws codecommit list-tags-for-resource \
    --resource-arn arn:aws:codecommit:us-west-2:111111111111:MyDemoRepo
```
輸出：  

```
{
    "tags": {
        "Status": "Secret",
        "Team": "Saanvi"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[檢視儲存庫的標籤](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-tag-repository-list.html#how-to-tag-repository-list-cli)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/list-tags-for-resource.html)。

### `merge-branches-by-fast-forward`
<a name="codecommit_MergeBranchesByFastForward_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-branches-by-fast-forward`。

**AWS CLI**  
**使用快轉合併策略合併兩個分支**  
下列 `merge-branches-by-fast-forward` 範例將指定的來源分支，與名為 `MyDemoRepo` 的儲存庫中的指定目的地分支合併。  

```
aws codecommit merge-branches-by-fast-forward \
    --source-commit-specifier bugfix-bug1234 \
    --destination-commit-specifier bugfix-bug1233 \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "commitId": "4f178133EXAMPLE",
    "treeId": "389765daEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[比較和合併分支](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-compare-branches.html#merge-branches-by-fast-forward)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [MergeBranchesByFastForward](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-branches-by-fast-forward.html)。

### `merge-branches-by-squash`
<a name="codecommit_MergeBranchesBySquash_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-branches-by-squash`。

**AWS CLI**  
**使用 squash 合併策略合併兩個分支**  
下列 `merge-branches-by-squash` 範例將指定的來源分支，與名為 `MyDemoRepo` 的儲存庫中的指定目的地分支合併。  

```
aws codecommit merge-branches-by-squash \
    --source-commit-specifier bugfix-bug1234 \
    --destination-commit-specifier bugfix-bug1233 \
    --author-name "Maria Garcia" \
    --email "maria_garcia@example.com" \
    --commit-message "Merging two fix branches to prepare for a general patch." \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "commitId": "4f178133EXAMPLE",
    "treeId": "389765daEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[比較和合併分支](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-compare-branches.html#merge-branches-by-squash)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [MergeBranchesBySquash](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-branches-by-squash.html)。

### `merge-branches-by-three-way`
<a name="codecommit_MergeBranchesByThreeWay_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-branches-by-three-way`。

**AWS CLI**  
**使用三向合併策略合併兩個分支**  
下列 `merge-branches-by-three-way` 範例將指定的來源分支，與名為 `MyDemoRepo` 的儲存庫中的指定目的地分支合併。  

```
aws codecommit merge-branches-by-three-way \
    --source-commit-specifier main \
    --destination-commit-specifier bugfix-bug1234 \
    --author-name "Jorge Souza" --email "jorge_souza@example.com" \
    --commit-message "Merging changes from main to bugfix branch before additional testing." \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "commitId": "4f178133EXAMPLE",
    "treeId": "389765daEXAMPLE"
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[比較和合併分支](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-compare-branches.html#merge-branches-by-three-way)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [MergeBranchesByThreeWay](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-branches-by-three-way.html)。

### `merge-pull-request-by-fast-forward`
<a name="codecommit_MergePullRequestByFastForward_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-pull-request-by-fast-forward`。

**AWS CLI**  
**合併與關閉提取請求**  
此範例展示如何在名為 `MyDemoRepo` 的儲存庫中合併和關閉 ID 為 '47'，和來源遞交 ID 為 '99132ab0EXAMPLE' 的提取請求。  

```
aws codecommit merge-pull-request-by-fast-forward \
    --pull-request-id 47 \
    --source-commit-id 99132ab0EXAMPLE \
    --repository-name MyDemoRepo
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "I want one approver for this pull request",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.142,
        "description": "Review the latest changes and updates to the global variables",
        "lastActivityDate": 1508887223.155,
        "pullRequestId": "47",
        "pullRequestStatus": "CLOSED",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": true,
                    "mergedBy": "arn:aws:iam::123456789012:user/Mary_Major"
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[合併提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-merge-pull-request.html#merge-pull-request-by-fast-forward)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [MergePullRequestByFastForward](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-pull-request-by-fast-forward.html)。

### `merge-pull-request-by-squash`
<a name="codecommit_MergePullRequestBySquash_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-pull-request-by-squash`。

**AWS CLI**  
**使用 squash 合併策略合併提取請求**  
下列 `merge-pull-request-by-squash` 範例使用名為 `MyDemoRepo` 的儲存庫中 ACCEPT\$1SOURCE 的衝突解決策略，合併和關閉指定的提取請求。  

```
aws codecommit merge-pull-request-by-squash \
    --pull-request-id 47 \
    --source-commit-id 99132ab0EXAMPLE \
    --repository-name MyDemoRepo \
    --conflict-detail-level LINE_LEVEL \
    --conflict-resolution-strategy ACCEPT_SOURCE \
    --name "Jorge Souza" --email "jorge_souza@example.com" \
    --commit-message "Merging pull request 47 by squash and accepting source in merge conflicts"
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approver-rule-for-main",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "originApprovalRuleTemplate": {
                    "approvalRuleTemplateId": "dd8b17fe-EXAMPLE",
                    "approvalRuleTemplateName": "2-approver-rule-for-main"
                },
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.142,
        "description": "Review the latest changes and updates to the global variables",
        "lastActivityDate": 1508887223.155,
        "pullRequestId": "47",
        "pullRequestStatus": "CLOSED",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": true,
                    "mergedBy": "arn:aws:iam::123456789012:user/Mary_Major"
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[合併提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-merge-pull-request.html#merge-pull-request-by-squash)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [MergePullRequestBySquash](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-pull-request-by-squash.html)。

### `merge-pull-request-by-three-way`
<a name="codecommit_MergePullRequestByThreeWay_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `merge-pull-request-by-three-way`。

**AWS CLI**  
**使用三向合併策略合併提取請求**  
下列 `merge-pull-request-by-three-way` 範例使用名為 `MyDemoRepo` 的儲存庫中衝突詳細資訊和衝突解決策略的預設選項，合併和關閉指定的提取請求。  

```
aws codecommit merge-pull-request-by-three-way \
    --pull-request-id 47 \
    --source-commit-id 99132ab0EXAMPLE \
    --repository-name MyDemoRepo \
    --name "Maria Garcia" \
    --email "maria_garcia@example.com" \
    --commit-message "Merging pull request 47 by three-way with default options"
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approver-rule-for-main",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "originApprovalRuleTemplate": {
                    "approvalRuleTemplateId": "dd8b17fe-EXAMPLE",
                    "approvalRuleTemplateName": "2-approver-rule-for-main"
                },
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.142,
        "description": "Review the latest changes and updates to the global variables",
        "lastActivityDate": 1508887223.155,
        "pullRequestId": "47",
        "pullRequestStatus": "CLOSED",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": true,
                    "mergedBy": "arn:aws:iam::123456789012:user/Mary_Major"
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[合併提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-merge-pull-request.html#merge-pull-request-by-three-way)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [MergePullRequestByThreeWay](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/merge-pull-request-by-three-way.html)。

### `override-pull-request-approval-rules`
<a name="codecommit_OverridePullRequestApprovalRules_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `override-pull-request-approval-rules`。

**AWS CLI**  
**覆寫提取請求的核准規則需求**  
下列 `override-pull-request-approval-rules` 範例會覆寫指定提取請求的核准規則。若要撤銷覆寫，請將 `--override-status` 參數值設定為 `REVOKE`。  

```
aws codecommit override-pull-request-approval-rules \
    --pull-request-id 34  \
    --revision-id 927df8d8EXAMPLE \
    --override-status OVERRIDE
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[覆寫提取請求的核准規則](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-override-approval-rules.html#override-approval-rules)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [OverridePullRequestApprovalRules](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/override-pull-request-approval-rules.html)。

### `post-comment-for-compared-commit`
<a name="codecommit_PostCommentForComparedCommit_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `post-comment-for-compared-commit`。

**AWS CLI**  
**建立對遞交的評論**  
此範例展示如何在名為 `MyDemoRepo` 的儲存庫中兩個遞交之間的比較中，將對於變更的評論 `"Can you add a test case for this?"` 新增至 `cl_sample.js` 檔案。  

```
aws codecommit post-comment-for-compared-commit \
    --repository-name MyDemoRepo \
    --before-commit-id 317f8570EXAMPLE \
    --after-commit-id 5d036259EXAMPLE \
    --client-request-token 123Example \
    --content "Can you add a test case for this?" \
    --location filePath=cl_sample.js,filePosition=1232,relativeFileVersion=AFTER
```
輸出：  

```
{
    "afterBlobId": "1f330709EXAMPLE",
    "afterCommitId": "317f8570EXAMPLE",
    "beforeBlobId": "80906a4cEXAMPLE",
    "beforeCommitId": "6e147360EXAMPLE",
    "comment": {
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "clientRequestToken": "",
        "commentId": "553b509bEXAMPLE56198325",
        "content": "Can you add a test case for this?",
        "creationDate": 1508369612.203,
        "deleted": false,
        "commentId": "abc123-EXAMPLE",
        "lastModifiedDate": 1508369612.203,
        "callerReactions": [],
        "reactionCounts": []
    },
    "location": {
        "filePath": "cl_sample.js",
        "filePosition": 1232,
        "relativeFileVersion": "AFTER"
    ,
    "repositoryName": "MyDemoRepo"
    }
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [PostCommentForComparedCommit](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/post-comment-for-compared-commit.html)。

### `post-comment-for-pull-request`
<a name="codecommit_PostCommentForPullRequest_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `post-comment-for-pull-request`。

**AWS CLI**  
**新增評論至提取請求**  
下列 `post-comment-for-pull-request` 範例將對於變更的評論 "These don't appear to be used anywhere. Can we remove them?"(這些似乎沒有在任何地方使用過。是否可以移除？) 新增至名為 `MyDemoRepo` 之儲存庫中 ID 為 `47` 的提取請求中的 `ahs_count.py` 檔案。  

```
aws codecommit post-comment-for-pull-request \
    --pull-request-id "47" \
    --repository-name MyDemoRepo \
    --before-commit-id 317f8570EXAMPLE \
    --after-commit-id 5d036259EXAMPLE \
    --client-request-token 123Example \
    --content "These don't appear to be used anywhere. Can we remove them?" \
    --location filePath=ahs_count.py,filePosition=367,relativeFileVersion=AFTER
```
輸出：  

```
{
     "afterBlobId": "1f330709EXAMPLE",
     "afterCommitId": "5d036259EXAMPLE",
     "beforeBlobId": "80906a4cEXAMPLE",
     "beforeCommitId": "317f8570EXAMPLE",
     "comment": {
            "authorArn": "arn:aws:iam::111111111111:user/Saanvi_Sarkar",
            "clientRequestToken": "123Example",
            "commentId": "abcd1234EXAMPLEb5678efgh",
            "content": "These don't appear to be used anywhere. Can we remove them?",
            "creationDate": 1508369622.123,
            "deleted": false,
            "CommentId": "",
            "lastModifiedDate": 1508369622.123,
            "callerReactions": [],
            "reactionCounts": []
        },
        "location": {
            "filePath": "ahs_count.py",
            "filePosition": 367,
            "relativeFileVersion": "AFTER"
         },
     "repositoryName": "MyDemoRepo",
     "pullRequestId": "47"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [PostCommentForPullRequest](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/post-comment-for-pull-request.html)。

### `post-comment-reply`
<a name="codecommit_PostCommentReply_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `post-comment-reply`。

**AWS CLI**  
**回覆遞交或提取請求中的評論**  
此範例展示如何使用系統產生的 ID `abcd1234EXAMPLEb5678efgh` 將回覆 `"Good catch. I'll remove them."` 新增至評論。  

```
aws codecommit post-comment-reply \
    --in-reply-to abcd1234EXAMPLEb5678efgh \
    --content "Good catch. I'll remove them." \
    --client-request-token 123Example
```
輸出：  

```
{
    "comment": {
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "clientRequestToken": "123Example",
        "commentId": "442b498bEXAMPLE5756813",
        "content": "Good catch. I'll remove them.",
        "creationDate": 1508369829.136,
        "deleted": false,
        "CommentId": "abcd1234EXAMPLEb5678efgh",
        "lastModifiedDate": 150836912.221,
        "callerReactions": [],
        "reactionCounts": []
    }
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [PostCommentReply](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/post-comment-reply.html)。

### `put-comment-reaction`
<a name="codecommit_PutCommentReaction_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `put-comment-reaction`。

**AWS CLI**  
**使用表情符號回覆對遞交的評論**  
下列 `put-comment-reaction` 範例利用 ID `abcd1234EXAMPLEb5678efgh` 且表情符號反應值 `:thumbsup:` 回覆評論。  

```
aws codecommit put-comment-reaction \
    --comment-id abcd1234EXAMPLEb5678efgh \
    --reaction-value :thumbsup:
```
此命令不會產生輸出。  
如需詳細資訊，請參閱 [AWS CodeCommit 使用者指南中的對遞交 inCodeCommit 的註解](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-commit-comment.html#how-to-commit-comment-cli-commit-reply-emoji)。 *AWS CodeCommit *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PutCommentReaction](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/put-comment-reaction.html)。

### `put-file`
<a name="codecommit_PutFile_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `put-file`。

**AWS CLI**  
**將檔案新增到儲存庫**  
下列 `put-file` 範例將名為 'ExampleSolution.py' 的檔案，新增至名為 'MyDemoRepo' 的儲存庫中，名為 'feature-randomizationfeature'，且其最近遞交的 ID 為 '4c925148EXAMPLE' 的分支。  

```
aws codecommit put-file \
    --repository-name MyDemoRepo \
    --branch-name feature-randomizationfeature \
    --file-content file://MyDirectory/ExampleSolution.py \
    --file-path /solutions/ExampleSolution.py \
    --parent-commit-id 4c925148EXAMPLE \
    --name "Maria Garcia" \
    --email "maria_garcia@example.com" \
    --commit-message "I added a third randomization routine."
```
輸出：  

```
{
    "blobId": "2eb4af3bEXAMPLE",
    "commitId": "317f8570EXAMPLE",
    "treeId": "347a3408EXAMPLE"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PutFile](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/put-file.html)。

### `put-repository-triggers`
<a name="codecommit_PutRepositoryTriggers_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `put-repository-triggers`。

**AWS CLI**  
**在儲存庫中新增或更新觸發條件**  
此範例展示如何使用已建立的 JSON 檔案 (此處名為 MyTriggers.json) 更新名為 'MyFirstTrigger' 和 'MySecondTrigger' 的觸發條件，其中包含名為 MyDemoRepo 之儲存庫的所有觸發條件結構。若要了解如何取得現有觸發條件的 JSON，請參閱 get-repository-triggers 命令。  

```
aws codecommit put-repository-triggers \
    --repository-name MyDemoRepo file://MyTriggers.json
```
`MyTriggers.json` 的內容：  

```
{
    "repositoryName": "MyDemoRepo",
    "triggers": [
        {
            "destinationArn": "arn:aws:sns:us-east-1:80398EXAMPLE:MyCodeCommitTopic",
            "branches": [
                "main",
                "preprod"
            ],
            "name": "MyFirstTrigger",
            "customData": "",
            "events": [
                "all"
            ]
        },
        {
            "destinationArn": "arn:aws:lambda:us-east-1:111111111111:function:MyCodeCommitPythonFunction",
            "branches": [],
            "name": "MySecondTrigger",
            "customData": "EXAMPLE",
            "events": [
                "all"
            ]
        }
    ]
}
```
輸出：  

```
{
    "configurationId": "6fa51cd8-35c1-EXAMPLE"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PutRepositoryTriggers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/put-repository-triggers.html)。

### `tag-resource`
<a name="codecommit_TagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `tag-resource`。

**AWS CLI**  
**將 AWS 標籤新增至現有的儲存庫**  
下列 `tag-resource` 範例使用兩個標籤來標記指定的儲存庫。  

```
aws codecommit tag-resource \
    --resource-arn arn:aws:codecommit:us-west-2:111111111111:MyDemoRepo \
    --tags Status=Secret,Team=Saanvi
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[新增標籤至儲存庫](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-tag-repository-add.html#how-to-tag-repository-add-cli)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/tag-resource.html)。

### `test-repository-triggers`
<a name="codecommit_TestRepositoryTriggers_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `test-repository-triggers`。

**AWS CLI**  
**在儲存庫中測試觸發**  
此範例示範如何在名為 MyDemoRepo 的CodeCommit 儲存庫中測試名為 'MyFirstTrigger' 的觸發條件。 AWS CodeCommit MyDemoRepo 在此範例中，儲存庫中的事件會從 Amazon Simple Notification Service (Amazon SNS) 主題觸發通知。  
命令：  

```
aws codecommit test-repository-triggers --repository-name MyDemoRepo --triggers name=MyFirstTrigger,destinationArn=arn:aws:sns:us-east-1:111111111111:MyCodeCommitTopic,branches=mainline,preprod,events=all
```
輸出：  

```
{
  "successfulExecutions": [
      "MyFirstTrigger"
  ],
  "failedExecutions": []
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TestRepositoryTriggers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/test-repository-triggers.html)。

### `untag-resource`
<a name="codecommit_UntagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `untag-resource`。

**AWS CLI**  
**從儲存庫移除 AWS 標籤**  
下列 `untag-resource` 範例從名為 `MyDemoRepo` 的儲存庫中移除具有指定索引鍵的標籤。  

```
aws codecommit untag-resource \
    --resource-arn arn:aws:codecommit:us-west-2:111111111111:MyDemoRepo \
    --tag-keys Status
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[從儲存庫移除標籤](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-tag-repository-delete.html#how-to-tag-repository-delete-cli)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/untag-resource.html)。

### `update-approval-rule-template-content`
<a name="codecommit_UpdateApprovalRuleTemplateContent_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-approval-rule-template-content`。

**AWS CLI**  
**更新核准規則範本的內容**  
下列 `update-approval-rule-template-content` 範例變更指定核准規則範本的內容，將核准集區重新定義為承擔角色 `CodeCommitReview` 的使用者。  

```
aws codecommit update-approval-rule-template-content \
    --approval-rule-template-name 1-approver-rule  \
    --new-rule-content "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}"
```
輸出：  

```
{
    "approvalRuleTemplate": {
        "creationDate": 1571352720.773,
        "approvalRuleTemplateDescription": "Requires 1 approval for all pull requests from the CodeCommitReview pool",
        "lastModifiedDate": 1571358728.41,
        "approvalRuleTemplateId": "41de97b7-EXAMPLE",
        "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
        "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
        "ruleContentSha256": "2f6c21a5EXAMPLE",
        "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan"
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#update-template-content)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApprovalRuleTemplateContent](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-approval-rule-template-content.html)。

### `update-approval-rule-template-description`
<a name="codecommit_UpdateApprovalRuleTemplateDescription_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-approval-rule-template-description`。

**AWS CLI**  
**更新核准規則範本的描述**  
下列 `update-approval-rule-template-description` 範例會將指定核准規則範本的描述變更為 `Requires 1 approval for all pull requests from the CodeCommitReview pool`：  

```
aws codecommit update-approval-rule-template-description \
    --approval-rule-template-name 1-approver-rule-for-all-pull-requests  \
    --approval-rule-template-description "Requires 1 approval for all pull requests from the CodeCommitReview pool"
```
輸出：  

```
{
  "approvalRuleTemplate": {
    "creationDate": 1571352720.773,
    "approvalRuleTemplateDescription": "Requires 1 approval for all pull requests from the CodeCommitReview pool",
    "lastModifiedDate": 1571358728.41,
    "approvalRuleTemplateId": "41de97b7-EXAMPLE",
    "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
    "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
    "ruleContentSha256": "2f6c21a5EXAMPLE",
    "lastModifiedUser": "arn:aws:iam::123456789012:user/Li_Juan"
  }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#update-template-description)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApprovalRuleTemplateDescription](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-approval-rule-template-description.html)。

### `update-approval-rule-template-name`
<a name="codecommit_UpdateApprovalRuleTemplateName_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-approval-rule-template-name`。

**AWS CLI**  
**更新核准規則範本的名稱**  
下列 `update-approval-rule-template-name` 範例將核准規則範本的名稱從 `1-approver-rule` 變更為 1-approver-rule-for-all-pull-requests`。  

```
aws codecommit update-approval-rule-template-name \
    --old-approval-rule-template-name 1-approver-rule  \
    --new-approval-rule-template-name 1-approver-rule-for-all-pull-requests
```
輸出：  

```
{
  "approvalRuleTemplate": {
    "approvalRuleTemplateName": "1-approver-rule-for-all-pull-requests",
    "lastModifiedDate": 1571358241.619,
    "approvalRuleTemplateId": "41de97b7-EXAMPLE",
    "approvalRuleTemplateContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 1,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
    "creationDate": 1571352720.773,
    "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
    "approvalRuleTemplateDescription": "All pull requests must be approved by one developer on the team.",
    "ruleContentSha256": "2f6c21a5cEXAMPLE"
  }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[管理核准規則範本](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-manage-templates.html#update-template-description)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApprovalRuleTemplateName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-approval-rule-template-name.html)。

### `update-comment`
<a name="codecommit_UpdateComment_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-comment`。

**AWS CLI**  
**更新對遞交的評論**  
此範例展示如何將內容 `"Fixed as requested. I'll update the pull request."` 新增至 ID 為 `442b498bEXAMPLE5756813` 的評論。  

```
aws codecommit update-comment \
    --comment-id 442b498bEXAMPLE5756813 \
    --content "Fixed as requested. I'll update the pull request."
```
輸出：  

```
{
    "comment": {
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "clientRequestToken": "",
        "commentId": "442b498bEXAMPLE5756813",
        "content": "Fixed as requested. I'll update the pull request.",
        "creationDate": 1508369929.783,
        "deleted": false,
        "lastModifiedDate": 1508369929.287,
        "callerReactions": [],
        "reactionCounts":
            {
                "THUMBSUP" : 2
            }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateComment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-comment.html)。

### `update-default-branch`
<a name="codecommit_UpdateDefaultBranch_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-default-branch`。

**AWS CLI**  
**變更儲存庫的預設分支**  
此範例會變更 AWS CodeCommit 儲存庫的預設分支。只有在發生錯誤時，此命令才會產生輸出。  
命令：  

```
aws codecommit update-default-branch --repository-name MyDemoRepo --default-branch-name MyNewBranch
```
輸出：  

```
None.
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateDefaultBranch](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-default-branch.html)。

### `update-pull-request-approval-rule-content`
<a name="codecommit_UpdatePullRequestApprovalRuleContent_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-pull-request-approval-rule-content`。

**AWS CLI**  
**編輯提取請求的核准規則**  
下列`update-pull-request-approval-rule-content`範例會更新她指定的核准規則，要求核准集區中包含`123456789012` AWS 帳戶中任何 IAM 使用者的使用者核准。  

```
aws codecommit update-pull-request-approval-rule-content \
    --pull-request-id 27  \
    --approval-rule-name "Require two approved approvers" \
    --approval-rule-content "{Version: 2018-11-08, Statements: [{Type: \"Approvers\", NumberOfApprovalsNeeded: 1, ApprovalPoolMembers:[\"CodeCommitApprovers:123456789012:user/*\"]}]}}"
```
輸出：  

```
{
    "approvalRule": {
        "approvalRuleContent": "{Version: 2018-11-08, Statements: [{Type: \"Approvers\", NumberOfApprovalsNeeded: 1, ApprovalPoolMembers:[\"CodeCommitApprovers:123456789012:user/*\"]}]}}",
        "approvalRuleId": "aac33506-EXAMPLE",
        "originApprovalRuleTemplate": {},
        "creationDate": 1570752871.932,
        "lastModifiedDate": 1570754058.333,
        "approvalRuleName": Require two approved approvers",
        "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
        "ruleContentSha256": "cd93921cEXAMPLE",
    }
}
```
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[編輯或刪除核准規則](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-edit-delete-pull-request-approval-rule.html#update-pull-request-approval-rule-content)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdatePullRequestApprovalRuleContent](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-pull-request-approval-rule-content.html)。

### `update-pull-request-approval-state`
<a name="codecommit_UpdatePullRequestApprovalState_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-pull-request-approval-state`。

**AWS CLI**  
**核准或撤銷核准提取請求**  
下列 `update-pull-request-approval-state` 範例核准 ID 為 `27` 且修訂 ID 為 `9f29d167EXAMPLE` 的提取請求。如果您想要改為撤銷核准，請將 `--approval-state` 參數值設定為 `REVOKE`。  

```
aws codecommit update-pull-request-approval-state \
    --pull-request-id 27  \
    --revision-id 9f29d167EXAMPLE  \
    --approval-state "APPROVE"
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CodeCommit 使用者指南*》中的[檢閱提取請求](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-review-pull-request.html#update-pull-request-approval-state)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdatePullRequestApprovalState](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-pull-request-approval-state.html)。

### `update-pull-request-description`
<a name="codecommit_UpdatePullRequestDescription_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-pull-request-description`。

**AWS CLI**  
**變更提取請求的描述**  
此範例展示如何變更 ID 為 `47` 之提取請求的描述。  

```
aws codecommit update-pull-request-description \
    --pull-request-id 47 \
    --description "Updated the pull request to remove unused global variable."
```
輸出：  

```
{
    "pullRequest": {
        "authorArn": "arn:aws:iam::111111111111:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.155,
        "description": "Updated the pull request to remove unused global variable.",
        "lastActivityDate": 1508372423.204,
        "pullRequestId": "47",
        "pullRequestStatus": "OPEN",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": false,
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdatePullRequestDescription](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-pull-request-description.html)。

### `update-pull-request-status`
<a name="codecommit_UpdatePullRequestStatus_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-pull-request-status`。

**AWS CLI**  
**變更提取請求的狀態**  
此範例示範如何在名為 的 AWS CodeCommit 儲存庫`CLOSED`中，將 ID `42`為 的提取請求狀態變更為 狀態`MyDemoRepo`。  

```
aws codecommit update-pull-request-status \
    --pull-request-id 42 \
    --pull-request-status CLOSED
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approvers-needed-for-this-change",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.165,
        "description": "Updated the pull request to remove unused global variable.",
        "lastActivityDate": 1508372423.12,
        "pullRequestId": "47",
        "pullRequestStatus": "CLOSED",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": false,
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdatePullRequestStatus](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-pull-request-status.html)。

### `update-pull-request-title`
<a name="codecommit_UpdatePullRequestTitle_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-pull-request-title`。

**AWS CLI**  
**變更提取請求的標題**  
此範例展示如何變更 ID 為 `47` 之提取請求的標題。  

```
aws codecommit update-pull-request-title \
    --pull-request-id 47 \
    --title "Consolidation of global variables - updated review"
```
輸出：  

```
{
    "pullRequest": {
        "approvalRules": [
            {
                "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"DestinationReferences\": [\"refs/heads/main\"],\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}",
                "approvalRuleId": "dd8b17fe-EXAMPLE",
                "approvalRuleName": "2-approver-rule-for-main",
                "creationDate": 1571356106.936,
                "lastModifiedDate": 571356106.936,
                "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major",
                "originApprovalRuleTemplate": {
                    "approvalRuleTemplateId": "dd8b26gr-EXAMPLE",
                    "approvalRuleTemplateName": "2-approver-rule-for-main"
                },
                "ruleContentSha256": "4711b576EXAMPLE"
            }
        ],
        "authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
        "clientRequestToken": "",
        "creationDate": 1508530823.12,
        "description": "Review the latest changes and updates to the global variables. I have updated this request with some changes, including removing some unused variables.",
        "lastActivityDate": 1508372657.188,
        "pullRequestId": "47",
        "pullRequestStatus": "OPEN",
        "pullRequestTargets": [
            {
                "destinationCommit": "9f31c968EXAMPLE",
                "destinationReference": "refs/heads/main",
                "mergeMetadata": {
                    "isMerged": false,
                },
                "repositoryName": "MyDemoRepo",
                "sourceCommit": "99132ab0EXAMPLE",
                "sourceReference": "refs/heads/variables-branch"
            }
        ],
        "title": "Consolidation of global variables - updated review"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdatePullRequestTitle](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-pull-request-title.html)。

### `update-repository-description`
<a name="codecommit_UpdateRepositoryDescription_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-repository-description`。

**AWS CLI**  
**變更儲存庫的描述**  
此範例會變更 AWS CodeCommit 儲存庫的描述。只有在發生錯誤時，此命令才會產生輸出。  
命令：  

```
aws codecommit update-repository-description --repository-name MyDemoRepo --repository-description "This description was changed"
```
輸出：  

```
None.
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateRepositoryDescription](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-repository-description.html)。

### `update-repository-name`
<a name="codecommit_UpdateRepositoryName_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-repository-name`。

**AWS CLI**  
**變更儲存庫的名稱**  
此範例會變更 AWS CodeCommit 儲存庫的名稱。只有在發生錯誤時，此命令才會產生輸出。變更 AWS CodeCommit 儲存庫的名稱會變更使用者連線到儲存庫所需的 SSH 和 HTTPS URLs。使用者將無法連接到此儲存庫，直到他們更新連線設定為止。此外，因為儲存庫的 ARN 將會變更，變更儲存庫名稱將使得仰賴於此儲存庫的 ARN 的任何 IAM 使用者政策無效。  
命令：  

```
aws codecommit update-repository-name --old-name MyDemoRepo --new-name MyRenamedDemoRepo
```
輸出：  

```
None.
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateRepositoryName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codecommit/update-repository-name.html)。