

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

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

此参考资料可帮助您了解如何使用 AWS CLI。

**要安装和配置 AWS CLI**

1. 在您的本地计算机上，下载并安装 AWS CLI。这是通过命令行与交互 CodeCommit 的先决条件。我们建议您安装 AWS CLI 版本 2。它是的最新主要版本 AWS CLI ，支持所有最新功能。它是唯一支持使用根账户、联合访问权限或临时证书的版本**git-remote-codecommit**。 AWS CLI 

   有关更多信息，请参阅[使用 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. 运行此命令以验证的 CodeCommit 命令 AWS CLI 是否已安装。

   ```
   aws codecommit help
   ```

   此命令返回 CodeCommit 命令列表。

1.  AWS CLI 使用**configure**命令配置配置文件，如下所示：。

   ```
   aws configure
   ```

   出现提示时，指定要与之 AWS 配合使用的 IAM 用户的访问 AWS 密钥和私有访问密钥 CodeCommit。另外，请务必指定存储库的 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 存储库](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-规则](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-规则](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-规则](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-提交](how-to-commit-comment.md#how-to-commit-comment-cli-get-comments)
+ [get-comments-for-pull-请求](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-州](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-规则模板](how-to-manage-templates.md#list-associated-repositories)
+ [list-tags-for-resource](how-to-tag-repository-list.md)
+ [merge-branches-by-fast-向前](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-快进](how-to-merge-pull-request.md#merge-pull-request-by-fast-forward)
+ [merge-pull-request-by-南瓜](how-to-merge-pull-request.md#merge-pull-request-by-squash)
+ [merge-pull-request-by-三向](how-to-merge-pull-request.md#merge-pull-request-by-three-way)
+ [override-pull-request-approval-规则](how-to-override-approval-rules.md#override-approval-rules)
+ [post-comment-for-compared-提交](how-to-commit-comment.md#how-to-commit-comment-cli-comment)
+ [post-comment-for-pull-请求](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-内容](how-to-manage-templates.md#update-template-content)
+ [update-approval-rule-template-描述](how-to-manage-templates.md#update-template-description)
+ [update-approval-rule-template-名字](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-规则内容](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)