Create an Amazon CodeCommit repository - Amazon CodeCommit
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Create an Amazon CodeCommit repository

Use the Amazon CodeCommit console or the Amazon Command Line Interface (Amazon CLI) to create an empty CodeCommit repository. To add tags to a respository after you create it, see Add a tag to a repository.

These instructions assume that you have completed the steps in Setting up .

Note

Depending on your usage, you might be charged for creating or accessing a repository. For more information, see Pricing on the CodeCommit product information page.

Create a repository (console)

To create a CodeCommit repository

  1. Open the CodeCommit console at https://console.www.amazonaws.cn/codesuite/codecommit/home.

  2. In the region selector, choose the Amazon Web Services Region where you want to create the repository. For more information, see Regions and Git connection endpoints.

  3. On the Repositories page, choose Create repository.

  4. On the Create repository page, in Repository name, enter a name for the repository.

    Note

    Repository names are case sensitive. The name must be unique in the Amazon Web Services Region for your Amazon Web Services account.

  5. (Optional) In Description, enter a description for the repository. This can help you and other users identify the purpose of the repository.

    Note

    The description field displays Markdown in the console and accepts all HTML characters and valid Unicode characters. If you are an application developer who is using the GetRepository or BatchGetRepositories APIs and you plan to display the repository description field in a web browser, see the CodeCommit API Reference.

  6. (Optional) Choose Add tag to add one or more repository tags (a custom attribute label that helps you organize and manage your Amazon resources) to your repository. For more information, see Tagging repositories in Amazon CodeCommit.

  7. (Optional) Expand Additional configuration to specify whether to use the default Amazon managed key or your own customer managed key for encrypting and decrypting data in this repository. If you choose to use your own customer managed key, you must ensure that it is available in the Amazon Web Services Region where you are creating the repository, and that the key is active. For more information, see Amazon Key Management Service and encryption for Amazon CodeCommit repositories.

  8. (Optional) Select Enable Amazon CodeGuru Reviewer for Java and Python if this repository contains Java or Python code, and you want CodeGuru Reviewer to analyze it. CodeGuru Reviewer uses multiple machine learning models to find code defects and to suggest improvements and fixes in pull requests. For more information, see the Amazon CodeGuru Reviewer User Guide.

  9. Choose Create.

After you create a repository, you can connect to it and start adding code either through the CodeCommit console or a local Git client, or by integrating your CodeCommit repository with your favorite IDE. For more information, see Setting up for Amazon CodeCommit. You can also add your repository to a continuous delivery pipeline. For more information, see Simple Pipeline Walkthrough.

To get information about the new CodeCommit repository, such as the URLs to use when cloning the repository, choose the repository's name from the list, or just choose the connection protocol you want to use next to the repository's name.

To share this repository with others, you must send them the HTTPS or SSH link to use to clone the repository. Make sure they have the permissions required to access the repository. For more information, see Share a repository and Authentication and access control for Amazon CodeCommit.

Create a repository (Amazon CLI)

You can use the Amazon CLI to create a CodeCommit repository. Unlike the console, you can add tags to a repository if you create it using the Amazon CLI.

  1. Make sure that you have configured the Amazon CLI with the Amazon Web Services Region where the repository exists. To verify the Region, run the following command at the command line or terminal and review the information for default region name.

    aws configure

    The default region name must match the Amazon Web Services Region for the repository in CodeCommit. For more information, see Regions and Git connection endpoints.

  2. Run the create-repository command, specifying:

    • A name that uniquely identifies the CodeCommit repository (with the --repository-name option).

      Note

      This name must be unique across an Amazon Web Services account.

    • An optional comment about the CodeCommit repository (with the --repository-description option).

    • An optional key-value pair or pairs to use as tags for the CodeCommit repository (with the --tags option).

    • An optional customer managed key to use when encrypting and decrypting this repository. All repositories are encrypted in transit and at rest using a key in Amazon KMS. If no key is specified, the default Amazon managed key aws/codecommit is used.

    For example, to create a CodeCommit repository named MyDemoRepo with the description "My demonstration repository" and a tag with a key named Team with the value of Saanvi, use this command.

    aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository" --tags Team=Saanvi
    Note

    The description field displays Markdown in the console and accepts all HTML characters and valid Unicode characters. If you are an application developer who is using the GetRepository or BatchGetRepositories APIs and you plan to display the repository description field in a web browser, see the CodeCommit API Reference.

  3. If successful, this command outputs a repositoryMetadata object with the following information:

    • The description (repositoryDescription).

    • The unique, system-generated ID (repositoryId).

    • The name (repositoryName).

    • The ID of the Amazon Web Services account associated with the CodeCommit repository (accountId).

    The following is example output, based on the preceding example command.

    { "repositoryMetadata": { "repositoryName": "MyDemoRepo", "cloneUrlSsh": "ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo", "lastModifiedDate": 1446071622.494, "repositoryDescription": "My demonstration repository", "cloneUrlHttp": "https://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo", "defaultBranch": main, "kmsKeyId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "creationDate": 1446071622.494, "repositoryId": "f7579e13-b83e-4027-aaef-650c0EXAMPLE", "Arn": "arn:aws:codecommit:us-east-2:111111111111:MyDemoRepo", "accountId": "111111111111" } }
    Note

    Tags that were added when the repository was created are not returned in the output. To view a list of tags associated with a repository, run the list-tags-for-resource command.

  4. Make a note of the name and ID of the CodeCommit repository. You need them to monitor and change information about the CodeCommit repository, especially if you use Amazon CLI.

    If you forget the name or ID, follow the instructions in View CodeCommit repository details (Amazon CLI).

After you create a repository, you can connect to it and start adding code. For more information, see Connect to a repository. You can also add your repository to a continuous delivery pipeline. For more information, see Simple Pipeline Walkthrough.