查看 CodeCommit 存储库详情 - AWS CodeCommit

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

查看 CodeCommit 存储库详情

您可以使用连接到 CodeCommit 存储库的本地存储库中的AWS CodeCommit控制台AWS CLI、或 Git 来查看有关可用存储库的信息。

在按照这些说明进行操作之前,请完成设置 中的步骤。

查看存储库详细信息(控制台)

使用 AWS CodeCommit 控制台可快速查看用您的 Amazon Web Services 账户创建的所有存储库。

  1. 打开 CodeCommit 控制台,网址为 https://console.aws.amazon.com/codesuite/codecommit/home

  2. 存储库中,查看您登录的 AWS 区域中的存储库相关详细信息。使用区域选择器选择不同的 AWS 区域,以查看相应区域中的存储库。

  3. 选择您要查看更多详情的存储库的名称,然后执行以下操作之一:

    • 要查看 URL 来克隆存储库,请选择 Clone URL (克隆 URL),然后选择克隆存储库时要使用的协议。此时将复制克隆 URL。要查看它,请将其粘贴到纯文本编辑器中。

    • 要查看存储库的可配置选项以及存储库 ARN 和存储库 ID 等详细信息,请在导航窗格中选择设置

注意

如果您以 IAM 用户身份登录,则可配置并保存用于查看代码的首选项和其他控制台设置。有关更多信息,请参阅使用用户首选项

查看 CodeCommit 仓库详情 (Git)

要使用本地存储库中的 Git 来查看 CodeCommit 存储库的详细信息,请运行git remote show命令。

在执行这些步骤之前,请将本地存储库连接到 CodeCommit 存储库。有关说明,请参阅连接存储库

  1. 运行git remote show remote-name命令,其中 remote-name 是 CodeCommit 存储库的别名(默认为)。origin

    提示

    要获取 CodeCommit 仓库名称及其 URL 的列表,请运行该git remote -v命令。

    例如,要查看别名为 CodeCommit 存储库的详细信息,请执行origin以下操作:

    git remote show origin
  2. 对于 HTTPS:

    * remote origin Fetch URL: https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo Push URL: https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo HEAD branch: (unknown) Remote branches: MyNewBranch tracked main tracked Local ref configured for 'git pull': MyNewBranch merges with remote MyNewBranch (up to date) Local refs configured for 'git push': MyNewBranch pushes to MyNewBranch (up to date) main pushes to main (up to date)

    对于 SSH:

    * remote origin Fetch URL: ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo Push URL: ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo HEAD branch: (unknown) Remote branches: MyNewBranch tracked main tracked Local ref configured for 'git pull': MyNewBranch merges with remote MyNewBranch (up to date) Local refs configured for 'git push': MyNewBranch pushes to MyNewBranch (up to date) main pushes to main (up to date)
    提示

    要查找您的 IAM 用户的 SSH 密钥 ID,请打开 IAM 控制台并在 IAM 用户详细信息页面上展开安全凭证。在 AWS CodeCommit 的 SSH 密钥中可找到 SSH 密钥 ID。

有关更多选项,请参阅 Git 文档。

查看 CodeCommit 存储库详细信息 (AWS CLI)

要将AWS CLI命令与一起使用 CodeCommit,请安装AWS CLI。有关更多信息,请参阅命令行参考

要使用 AWS CLI 查看存储库详细信息,请运行以下命令:

  • 要查看 CodeCommit 仓库名称及其对应 ID 的列表,请运行列表存储库

  • 要查看有关单个 CodeCommit 存储库的信息,请运行 get- repository。

  • 要查看有关中多个存储库的信息 CodeCommit,请运行batch-get-repositories

查看 CodeCommit 存储库列表

  1. 运行 list-repositories 命令:

    aws codecommit list-repositories

    您可以使用可选的 --sort-by--order 选项来更改返回信息的顺序。

  2. 如果成功,此命令将输出一个repositories对象,其中包含与 Amazon Web Services 账户 CodeCommit 关联的所有存储库的名称和 ID。

    下面是前面命令的一些示例输出:

    { "repositories": [ { "repositoryName": "MyDemoRepo", "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE" }, { "repositoryName": "MyOtherDemoRepo", "repositoryId": "cfc29ac4-b0cb-44dc-9990-f6f51EXAMPLE" } ] }

查看有关单个 CodeCommit 存储库的详细信息

  1. 运行get-repository命令,使用--repository-name选项指定 CodeCommit 存储库的名称。

    提示

    要获取 CodeCommit 存储库的名称,请运行列表存储库命令。

    例如,要查看名为的 CodeCommit 存储库的详细信息MyDemoRepo

    aws codecommit get-repository --repository-name MyDemoRepo
  2. 如果成功,此命令会输出一个包含以下信息的 repositoryMetadata 对象:

    • 存储库的名称 (repositoryName)。

    • 存储库说明 (repositoryDescription)。

    • 系统生成的存储库的唯一 ID (repositoryId)。

    • 与存储库关联的 Amazon Web Services 账户的 ID (accountId)。

    下面是前面示例命令的一些示例输出:

    { "repositoryMetadata": { "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" } }

查看有关多个 CodeCommit 存储库的详细信息

  1. 使用 batch-get-repositories 选项运行 --repository-names 命令。在每个 CodeCommit 存储库名称之间添加一个空格。

    提示

    要获取存储库的名称,请运行 list- CodeCommit repositories 命令。

    例如,要查看名为MyDemoRepo和的两个 CodeCommit 存储库的详细信息,请执行MyOtherDemoRepo以下操作:

    aws codecommit batch-get-repositories --repository-names MyDemoRepo MyOtherDemoRepo
  2. 如果成功,此命令会输出一个包含以下信息的对象:

    • 找不到的所有 CodeCommit 存储库的列表 (repositoriesNotFound)。

    • CodeCommit 存储库列表 (repositories)。每个 CodeCommit 存储库名称后面都有:

      • 存储库说明 (repositoryDescription)。

      • 系统生成的存储库的唯一 ID (repositoryId)。

      • 与存储库关联的 Amazon Web Services 账户的 ID (accountId)。

    下面是前面示例命令的一些示例输出:

    { "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": [] }