AWS CodeCommit
User Guide (API Version 2015-04-13)

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Getting Started with AWS CodeCommit Tutorial

If you're new to CodeCommit, this tutorial helps you learn how to use its features. In this tutorial, you create a repository in CodeCommit. After you commit some changes to the CodeCommit repository, you browse the files and view the changes. You can also create a pull request for others to review and comment on changes to your code.

The CodeCommit console includes helpful information in a collapsible panel that you can open from the information icon or any Info link on the page. ( ). You can close this panel at any time.

            Viewing additional guidance in the console

The CodeCommit console also provides a way to quickly search for your resources, such as repositories, build projects, deployment applications, and pipelines. Choose Go to resource or press the / key, and then type the name of the resource. Any matches appear in the list. Searches are case insensitive. You only see resources that you have permissions to view. For more information, see Viewing Resources in the Console.

If you are not familiar with Git, you might want to complete the Git with CodeCommit Tutorial in addition to this tutorial. After you finish this tutorial, you should have enough practice to start using CodeCommit for your own projects and in team environments.


Before you begin, you must complete the prerequisites and setup, including:

  • Assigning permissions to the IAM user.

  • Setting up credential management for HTTPS or SSH connections on the local machine you use for this tutorial.

  • Configuring the AWS CLI if you want to use the command line or terminal for all operations, including to create the repository.

Step 1: Create a CodeCommit Repository

You can use the CodeCommit console to create a CodeCommit repository. If you already have a repository you want to use for this tutorial, you can skip this step.


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.

To create the CodeCommit repository

  1. Open the CodeCommit console at

  2. In the region selector, choose the AWS 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 your repository (for example, MyDemoRepo).


    Repository names are case sensitive and can be no longer than 100 characters. For more information, see Limits.

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

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

  7. Choose Create.

              Creating a repository from the console


If you use a name other than MyDemoRepo for your repository, be sure to use it in the remaining steps of this tutorial.

When the repository opens, you see information about how to add files directly from the CodeCommit console.

Step 2: Add Files to Your Repository

You can add files to your repository by:

  • Creating a file in the CodeCommit console.

  • Uploading a file from your local computer using the CodeCommit console.

  • Using a Git client to clone the repository to your local computer, and then adding, committing, and pushing files to the CodeCommit repository.

The simplest way to get started is to add a file from the CodeCommit console.

  1. In the navigation bar for the repository, choose Code.

  2. Choose Add file, and then choose to create or upload a file from your computer.

  3. Do the following:

    • If you want to add the file to a different branch, from the drop-down list of branches, choose the branch where you want to add the file. The default branch is selected automatically for you. In the example shown here, the default branch is named master.

    • In Author name, enter the name you want displayed to other repository users.

    • In Email address, enter an email address.

    • (Optional) In Commit message, enter a brief message. Although this is optional, we recommend that you add a commit message to help your team members understand why you added this file. If you do not enter a commit message, a default message is used.

    • If you're uploading a file, choose the file you want to upload.

    • If you're creating a file, in File name, enter a name for the file, and then in the code editor, enter the code you want to add.

                        A view of uploading a file in the CodeCommit console
  4. Choose Commit changes.

For more information, see Working with Files in AWS CodeCommit Repositories.

To use a Git client to clone the repository, install Git on your local computer, and then clone the CodeCommit repository. Add some files to the local repo and push them to the CodeCommit repository. For an in-depth introduction, try the Git with CodeCommit Tutorial. If you are familiar with Git, but are not sure how to do this with a CodeCommit repository, you can view examples and instructions in Create a Commit, Step 2: Create a Local Repo, or Connect to a Repository.

After you have added some files to the CodeCommit repository, you can view them in the console.

Step 3: Browse the Contents of Your Repository

You can use the CodeCommit console to review the files in a repository or quickly read the contents of a file. This helps you determine which branch to check out or whether to create a local copy of a repository.

  1. From Repositories, choose MyDemoRepo.

  2. The contents of the repository are displayed in the default branch for your repository. To change the view to another branch, or to view the code at a specific tag, choose the view selector button, and then choose the branch or tag you want to view from the list. Here the view is set to the master branch.

                        Browse the contents of a repository
  3. To view the contents of a file in your repository, choose the file from the list. Choose the gear icon to change the color display option of the displayed code.

                        View the contents of a file

For more information, see Browse Files in a Repository.

You can also browse the commit history of a repository. This helps you identify changes made in a repository, including when and by whom those changes were made.

  1. In the navigation pane for a repository, choose Commits. A history of commits for the repository in the default branch is displayed, in reverse chronological order.

                        The commit history view in the console
  2. Review the commit history by branch or by tag, and get details about commits by author, date, and more.

  3. To view the differences between a commit and its parent, choose the abbreviated commit ID. You can choose how the changes are displayed, including showing or hiding white space changes, and whether to view changes inline (Unified view) or side by side (Split view).


    Your preferences for viewing code and other console settings are saved as browser cookies whenever you change them. For more information, see Working with User Preferences.

                        Changes shown in Unified view, with white space
                            changes visible
  4. To view all comments on a commit, choose the commit and then scroll through the changes to view them inline. You can also add your own comments and reply to the comments made by others.

    For more information, see Comment on a Commit.

  5. To view the differences between any two commits specifiers, including tags, branches, and commit IDs, in the navigation pane, choose Commits, and then choose Compare commits.

                        Comparing a commit to the tip of a branch in Split view

    For more information, see Browse the Commit History of a Repository and Compare Commits.

  6. In Commits, choose the Commit visualizer tab.

                        A graphical view of a repository in the console

    The commit graph is displayed, with the subject line for each commit shown next to its point in the graph. The subject line display is limited to 80 characters.

  7. To see more details about a commit, choose its abbreviated commit ID. To render the graph from a specific commit, choose that point in the graph. For more information, see View a Graph of the Commit History of a Repository .

Step 4: Create and Collaborate on a Pull Request

When you work with other repository users, you might want to collaborate on code and review changes. You can create a pull request so that other users can review and comment on your code changes in a branch before you merge those changes into another branch. If you set up notifications for your repository, repository users can receive emails about repository events (for example, for pull requests or when someone comments on code). For more information, see Configuring Notifications for Events in an AWS CodeCommit Repository.


Before you can create a pull request, you must create a branch that contains the code changes you want to review. For more information, see Create a Branch.

  1. In the navigation pane, choose Pull requests.

  2. In Pull request, choose Create pull request.


    You can also create pull requests from Branches and Code.

    In Create pull request, in Source, choose the branch that contains the changes you want reviewed. In Destination, choose the branch where you want the reviewed code to be merged when the pull request is closed. Choose Compare.

  3. Review the merge details and changes to confirm that the pull request contains the changes and commits you want reviewed. If so, in Title, enter a title for this review. This is the title that appears in the list of pull requests for the repository. In Description, enter details about what this review is about and any other useful information for reviewers. Choose Create.

                        Creating a pull request
  4. Your pull request appears in the list of pull requests for the repository. You can filter the view to show only open requests, closed requests, requests that you created, and more.

                        Viewing pull requests in a repository
  5. If you configured notifications for your repository and chose to notify users of pull request events, users receive email about your new pull request. Users can view the changes and comment on specific lines of code, files, and the pull request itself. They can also reply to comments. If necessary, you can push changes to the pull request branch, which updates the pull request.

                        Viewing activity in a pull request
  6. When you are satisfied that all the code changes have been reviewed and agreed to, from the pull request, do one of the following:

    • If you want to merge the branches as part of closing the pull request, choose Merge. You can choose between the merge strategies available for your code, which depend on the differences between the source and destination branches, and whether to automatically delete the source branch after the merge is complete. After you have made your choices, choose Merge pull request to complete the merge.

                                A pull request showing the merge strategies available for
                                    the merge in the CodeCommit console.
    • If you want to close the pull request without merging branches, choose Close pull request.

    • If there are merge conflicts in the branches that cannot be resolved automatically, you can try to resolve them in the CodeCommit console, or you can use your local Git client to merge the branches and then push the merge. For more information, see Resolve Conflicts in a Pull Request in an AWS CodeCommit Repository.


    You can always manually merge branches, including pull request branches, by using the git merge command in your local repo and pushing your changes.

For more information, see Working with Pull Requests.

Step 5: Next Steps

Now that you have familiarized yourself with CodeCommit and some of its features, consider doing the following:

Step 6: Clean Up

If you no longer need the CodeCommit repository, you should delete the CodeCommit repository and other resources you used in this tutorial so you won't continue to be charged for the storage space.


After you delete this repository, you can no longer clone it to any local repo or shared repo. You also can no longer pull data from or push data to it, or perform any Git operations, from any local repo or shared repo. This action cannot be undone.

If you configured notifications for your repository, deleting the repository also deletes the Amazon CloudWatch Events rule created for the repository. It does not delete the Amazon SNS topic used as a target for that rule.

If you configured triggers for your repository, deleting the repository does not delete the Amazon SNS topics or Lambda functions you configured as the targets of those triggers. Be sure to delete those resources if you don't need them. For more information, see Delete Triggers from a Repository.

To delete the CodeCommit repository

  1. Open the CodeCommit console at

  2. In Repositories, choose the repository you want to delete. If you followed the naming convention in this topic, it is named MyDemoRepo.

  3. In the navigation pane, choose Settings.

  4. On the Settings page, in Delete repository, choose Delete repository.

  5. Type delete, and then choose Delete. The repository is permanently deleted.