

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

# AWS CodeCommit 命令列參考
<a name="cmd-ref"></a>

此參考協助您了解如何使用 AWS CLI。

**安裝和設定 AWS CLI**

1. 在本機電腦上，下載並安裝 AWS CLI。這是從命令列與 CodeCommit 互動的先決條件。我們建議您安裝 AWS CLI 第 2 版。這是 的最新主要版本， AWS CLI 並支援所有最新功能。這是 唯一 AWS CLI 支援搭配 使用根帳戶、聯合存取或臨時憑證的 版本**git-remote-codecommit**。

   如需詳細資訊，請參閱[使用 AWS 命令列界面進行設定](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html)。
**注意**  
CodeCommit 僅適用於 1.7.38 版和更新 AWS CLI 版本。最佳實務是安裝 或 AWS CLI 將 升級至可用的最新版本。若要判斷 AWS CLI 您已安裝的 版本，請執行 **aws --version**命令。  
若要 AWS CLI 將舊版 升級至最新版本，請參閱[安裝 AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)。

1. 執行此命令，以確認 AWS CLI 已安裝 的 CodeCommit 命令。

   ```
   aws codecommit help
   ```

   此命令會傳回 CodeCommit 命令的清單。

1. 使用 **configure**命令 AWS CLI 以設定檔設定 ，如下所示：

   ```
   aws configure
   ```

   出現提示時，請指定要與 CodeCommit 搭配使用之 IAM 使用者的 AWS 存取金鑰和 AWS 私密存取金鑰。此外，請務必指定儲存 AWS 區域 庫所在的 ，例如 `us-east-2`。系統提示您輸入預設輸出格式時，請指定 `json`。例如，如果您為 IAM 使用者設定設定檔：

   ```
   AWS Access Key ID [None]: Type your IAM user AWS access key ID here, and then press Enter
   AWS Secret Access Key [None]: Type your IAM user AWS secret access key here, and then press Enter
   Default region name [None]: Type a supported region for CodeCommit here, and then press Enter
   Default output format [None]: Type json here, and then press Enter
   ```

   如需建立和設定設定檔以搭配 使用的詳細資訊 AWS CLI，請參閱下列內容：
   + [命名設定檔](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
   + [在 中使用 IAM 角色 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html)
   + [設定命令](https://docs.aws.amazon.com/cli/latest/reference/set.html)
   + [使用輪換憑證連線至 AWS CodeCommit 儲存庫](temporary-access.md)

   若要連線到儲存庫或其他資源 AWS 區域，您必須 AWS CLI 使用預設區域名稱重新設定 。CodeCommit 支援的預設區域名稱包括：
   + us-east-2
   + us-east-1
   + eu-west-1
   + us-west-2
   + ap-northeast-1
   + ap-southeast-1
   + ap-southeast-2
   + ap-southeast-3
   + me-central-1
   + eu-central-1
   + ap-northeast-2
   + sa-east-1
   + us-west-1
   + eu-west-2
   + ap-south-1
   + ap-south-1
   + ca-central-1
   + us-gov-west-1
   + us-gov-east-1
   + eu-north-1
   + ap-east-1
   + me-south-1
   + cn-north-1
   + cn-northwest-1
   + eu-south-1
   + ap-northeast-3
   + af-south-1
   + il-central-1

   如需 CodeCommit 和 的詳細資訊 AWS 區域，請參閱 [區域和 Git 連線端點](regions.md)。如需 IAM、存取金鑰和私密金鑰的詳細資訊，請參閱[如何取得登入資料？](https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_Introduction.html#IAM_SecurityCredentials)以及[管理 IAM 使用者的存取金鑰](https://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingCredentials.html)。如需 AWS CLI 和 設定檔的詳細資訊，請參閱[具名設定檔](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)。

若要檢視所有可用 CodeCommit 命令的清單，請執行下列命令：

```
aws codecommit help
```

若要檢視 CodeCommit 命令的相關資訊，請執行下列命令，其中 *command-name* 是命令的名稱 （例如 **create-repository**)：

```
aws codecommit command-name help
```

請參閱以下章節以檢視 AWS CLI中的命令描述和範例用法：
+ [associate-approval-rule-template-with-repository](how-to-associate-template.md#associate-template-repository)
+ [batch-associate-approval-rule-template-with-repositories](how-to-associate-template.md#batch-associate-template-repositories)
+ [batch-disassociate-approval-rule-template-from-repositories](how-to-disassociate-template.md#batch-disassociate-template)
+ [batch-describe-merge-conflicts](how-to-resolve-conflict-pull-request.md#batch-describe-merge-conflicts)
+ [batch-get-commits](how-to-view-commit-details.md#how-to-view-commit-details-cli-batch-get-commits)
+ [batch-get-repositories](how-to-view-repository-details.md#how-to-view-repository-details-with-names-cli)
+ [create-approval-rule-template](how-to-create-template.md#create-template-cli)
+ [create-branch](how-to-create-branch.md#how-to-create-branch-cli)
+ [create-commit](how-to-create-commit.md#how-to-create-commit-cli)
+ [create-pull-request](how-to-create-pull-request.md#how-to-create-pull-request-cli)
+ [create-pull-request-approval-rule](how-to-create-pull-request-approval-rule.md#how-to-create-pull-request-approval-rule-cli)
+ [create-repository](how-to-create-repository.md#how-to-create-repository-cli)
+ [create-unreferenced-merge-commit](how-to-resolve-conflict-pull-request.md#create-unreferenced-merge-commit)
+ [delete-approval-rule-template](how-to-delete-template.md#delete-template)
+ [delete-branch](how-to-delete-branch.md#how-to-delete-branch-cli)
+ [delete-comment-content](how-to-commit-comment.md#how-to-commit-comment-cli-commit-delete)
+ [delete-file](how-to-edit-file.md#how-to-edit-file-cli)
+ [delete-repository](how-to-delete-repository.md#how-to-delete-repository-cli)
+ [describe-merge-conflicts](how-to-resolve-conflict-pull-request.md#describe-merge-conflicts)
+ [delete-pull-request-approval-rule](how-to-edit-delete-pull-request-approval-rule.md#delete-pull-request-approval-rule)
+ [describe-pull-request-events](how-to-view-pull-request.md#describe-pull-request-events)
+ [disassociate-pull-request-approval-rule-template-from-repository](how-to-disassociate-template.md#disassociate-template)
+ [evaluate-pull-request-approval-rules](how-to-merge-pull-request.md#evaluate-pull-request-approval-rules)
+ [get-approval-rule-template](how-to-manage-templates.md#get-template)
+ [get-blob](how-to-view-commit-details.md#how-to-view-commit-details-cli-blob)
+ [get-branch](how-to-view-branch-details.md#how-to-view-branch-details-cli-details)
+ [get-comment](how-to-commit-comment.md#how-to-commit-comment-cli-get-comment-info)
+ [get-comment-reactions](how-to-commit-comment.md#how-to-commit-comment-cli-commit-emoji-view)
+ [get-comments-for-compared-commit](how-to-commit-comment.md#how-to-commit-comment-cli-get-comments)
+ [get-comments-for-pull-request](how-to-review-pull-request.md#get-comments-for-pull-request)
+ [get-commit](how-to-view-commit-details.md#how-to-view-commit-details-cli-commit)
+ [get-differences](how-to-view-commit-details.md#how-to-view-commit-details-cli-differences)
+ [get-merge-commit](how-to-view-commit-details.md#how-to-view-commit-details-cli-merge-commit)
+ [get-merge-conflicts](how-to-view-pull-request.md#get-merge-conflicts)
+ [get-merge-options](how-to-resolve-conflict-pull-request.md#get-merge-options)
+ [get-pull-request](how-to-view-pull-request.md#get-pull-request)
+ [get-pull-request-approval-states](how-to-view-pull-request.md#get-pull-request-approval-state)
+ [get-pull-request-override-state](how-to-override-approval-rules.md#get-override-status)
+ [get-repository](how-to-view-repository-details.md#how-to-view-repository-details-with-name-cli)
+ [get-repository-triggers](how-to-notify-edit.md#how-to-notify-edit-cli)
+ [list-approval-rule-templates](how-to-manage-templates.md#list-templates)
+ [list-associated-approval-rule-templates-for-repository](how-to-manage-templates.md#list-associated-templates)
+ [list-branches](how-to-view-branch-details.md#how-to-view-branch-details-cli)
+ [list-pull-requests](how-to-view-pull-request.md#list-pull-requests)
+ [list-repositories](how-to-view-repository-details.md#how-to-view-repository-details-no-name-cli)
+ [list-repositories-for-approval-rule-template](how-to-manage-templates.md#list-associated-repositories)
+ [list-tags-for-resource](how-to-tag-repository-list.md)
+ [merge-branches-by-fast-forward](how-to-compare-branches.md#merge-branches-by-fast-forward)
+ [merge-branches-by-squash](how-to-compare-branches.md#merge-branches-by-squash)
+ [merge-branches-by-three-way](how-to-compare-branches.md#merge-branches-by-three-way)
+ [merge-pull-request-by-fast-forward](how-to-merge-pull-request.md#merge-pull-request-by-fast-forward)
+ [merge-pull-request-by-squash](how-to-merge-pull-request.md#merge-pull-request-by-squash)
+ [merge-pull-request-by-three-way](how-to-merge-pull-request.md#merge-pull-request-by-three-way)
+ [override-pull-request-approval-rules](how-to-override-approval-rules.md#override-approval-rules)
+ [post-comment-for-compared-commit](how-to-commit-comment.md#how-to-commit-comment-cli-comment)
+ [post-comment-for-pull-request](how-to-review-pull-request.md#post-comment-for-pull-request)
+ [post-comment-reply](how-to-commit-comment.md#how-to-commit-comment-cli-commit-reply)
+ [put-comment-reaction](how-to-commit-comment.md#how-to-commit-comment-cli-commit-reply-emoji)
+ [put-file](how-to-create-file.md#how-to-create-file-cli)
+ [put-repository-triggers](how-to-notify-edit.md#how-to-notify-edit-cli)
+ [tag-resource](how-to-tag-repository-add.md)
+ [test-repository-triggers](how-to-notify-test.md#how-to-notify-test-cli)
+ [untag-resource](how-to-tag-repository-delete.md)
+ [update-approval-rule-template-content](how-to-manage-templates.md#update-template-content)
+ [update-approval-rule-template-description](how-to-manage-templates.md#update-template-description)
+ [update-approval-rule-template-name](how-to-manage-templates.md#update-template-name)
+ [update-comment](how-to-commit-comment.md#how-to-commit-comment-cli-commit-update)
+ [update-default-branch](how-to-change-branch.md#how-to-change-branch-cli-default)
+ [update-pull-request-approval-rule-content](how-to-edit-delete-pull-request-approval-rule.md#update-pull-request-approval-rule-content)
+ [update-pull-request-approval-state](how-to-review-pull-request.md#update-pull-request-approval-state)
+ [update-pull-request-description](how-to-update-pull-request.md#update-pull-request-description)
+ [update-pull-request-status](how-to-close-pull-request.md#update-pull-request-status)
+ [update-pull-request-title](how-to-update-pull-request.md#update-pull-request-title)
+ [update-repository-description](how-to-change-repository.md#how-to-change-repository-cli-description)
+ [update-repository-name](how-to-change-repository.md#how-to-change-repository-cli-name)