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

Getting Started with AWS CodeCommit Tutorial

If you're new to AWS CodeCommit, this tutorial helps you learn how to use its features. In this tutorial, you create a repository in AWS CodeCommit. After you create a local copy of that repository (a local repo) and push some changes to the AWS CodeCommit repository, you will browse the files you pushed and view the changes. You can also create a pull request for others to review and comment on changes to your code.

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

Important

Before you begin this tutorial, 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 creating the repository.

Step 1: Create an AWS CodeCommit Repository

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

Note

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

To create the AWS CodeCommit repository (console)

  1. Open the AWS CodeCommit console at https://console.aws.amazon.com/codecommit.

  2. In the region selector, choose the region where you will create the repository. For more information, see Regions and Git Connection Endpoints.

  3. On the Welcome page, choose Get Started Now. (If a Dashboard page appears instead, choose Create repository.)

  4. On the Create repository page, in the Repository name box, type a name (for example, MyDemoRepo).

  5. In Description, type a description (for example, My demonstration repository).

  6. Choose Create repository.

  7. In Configure email notifications, configure notifications so that repository users receive emails about important repository events. This step is optional, but recommended. You can choose the event types (for example, comments on code) and whether to use an existing Amazon SNS topic or create one specifically for this purpose. You can choose to skip this step and configure notifications at a later time. For more information, see Configuring Notifications for Events in an AWS CodeCommit Repository.


              Creating a repository from the console

Note

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

The newly-created repository opens and displays guidance for connecting to it from your local computer. Open a terminal or command line on your local computer and follow the instructions to clone the repository. Once you have cloned it, add some files to the local repo and push them to the AWS CodeCommit repository. If you are not sure how to do this, you can view examples and instructions in Create a Commit, Step 2: Create a Local Repo, or Connect to a Repository. For an in-depth introduction, try the Git with AWS CodeCommit Tutorial.

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

Step 2: Browse the Contents of Your Repository

In this step, you browse the contents of your repository. You can use the AWS CodeCommit console to review the files in a repository or to quickly read the contents of a file. This can help you determine which branch to check out or whether to create a local copy of a repository.

  1. From the AWS CodeCommit console, choose MyDemoRepo from the list of repositories.

  2. The contents of the repository are displayed in the default branch for your repository. To change the view to another branch, choose the view selector button (here the view is set to Branch: master), and then choose the branch you want to view from the list.

    
                  Browse the contents of a repository
  3. To view the contents of a file in your repository, choose the file from the list.

    
                  View the contents of a file

For more information, see Browse the Contents of a Repository.

You can also browse the commit history of a repository. This can help 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. In the commit history view, 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. Changes are displayed. You can choose how the changes are displayed, including showing or hiding whitespace changes, and whether to view changes inline (Unified view) or side by side (Split view).

    Note

    If you are signed in as an IAM user, you can configure and save your preferences for viewing code and other console settings. For more information, see Working with User Preferences.

    
                        Changes shown in Split view, with white space
                            changes visible
  4. To view all comments on a commit, choose Comments, or 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 Compare.

    
                        Comparing a commit to the tip of the master branch in Unified
                            view

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

  6. In the navigation pane, choose Visualizer.

    
                      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 point in the graph.

    
                      A detail view of a commit point

    You can review the information in the detail pane, copy commit and parent commit IDs, render a graph from a different point, and more. For more information, see View a Graph of the Commit History of a Repository .

Now that you have reviewed the content of your repository, consider whether you want to create a trigger. A trigger is an action that is taken in response to events in that repository, such as a push to a specific branch.

Step 3: Create and Collaborate on a Pull Request

In this step, you create a pull request so that other users of the repository can review and comment on your code changes in a branch before you merge those changes to another branch.

Important

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 Branches.

  2. In Branches, find the branch that contains the changes you want reviewed, and then choose Create pull request.

    
                        A view of branches in a repository
  3. In Create pull request, in Source, choose the branch that contains the changes you want reviewed. By default, the destination branch is preconfigured for you with the default branch of the repository. Optionally choose a different branch if you want to merge code to a different branch when the pull request is complete, and then choose Compare.

  4. Review the merge details and the changes to help ensure that the pull request contains the changes and commits you want reviewed. If so, in Details, provide a title for this review. This is the title that will appear in the list of pull requests for the repository. In Description, provide details about what this review is about and any other useful information for reviewers. Choose Create.

    
                            Creating a pull request
  5. 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

    Tip

    You can create pull requests directly from the Pull requests view.

  6. If you configured notifications for your repository and chose to notify users of pull request events, users will 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, as well as reply to comments. If necessary, you can push changes to the pull request branch, which will update the pull request.

    
                        Replying to a comment on a pull request
  7. When you are satisfied that all the code changes have been reviewed and users are in agreement about the changes, from the pull request, choose either Merge (if you want to automatically merge the branches as part of closing the pull request using the fast-forward merge option) or Close pull request (if you want to close the pull request without using the automatic fast-forward merge option to merge branches, or if there are merge conflicts in the branches that cannot be automatically resolved).

    Note

    You can always manually merge branches, including pull request branches, by using the git merge command in your local repo and pushing your changes. AWS CodeCommit will automatically close the pull request when you push the merged code.

For more information, see Working with Pull Requests.

Step 4: Next Steps

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

Step 5: Clean Up

In this step, you delete the AWS CodeCommit repository and other resources you used in this tutorial, so you won't continue to be charged for the storage space.

Important

After you delete this repository, you will no longer be able to clone it to any local repo or shared repo. You will also no longer be able to pull data from it, 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 will also delete the Amazon CloudWatch Events rule created for the repository. It will 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 AWS CodeCommit repository

  1. Open the AWS CodeCommit console at https://console.aws.amazon.com/codecommit.

  2. On the Dashboard page, in the list of repositories, choose MyDemoRepo.

  3. In the navigation pane, choose Settings.

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

  5. In the box next to Type the name of the repository to confirm deletion, type MyDemoRepo, and then choose Delete.